These functions all cooperate to free memory pointed to by a single
object that contains (doesn't *point to*, but acutally contains)
several sub-objects. They were written to send copies of these
sub-objects to subordinate functions, rather than just sending
pointers to the sub-objects.
Let's change these functions to just send pointers to the objects
they're cleaning out rather than all the wasteful and pointless
copying.
Signed-off-by: Laine Stump <laine(a)redhat.com>
---
src/qemu/qemu_firmware.c | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c
index c22b1f1e9c..aad39ee038 100644
--- a/src/qemu/qemu_firmware.c
+++ b/src/qemu/qemu_firmware.c
@@ -188,47 +188,47 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuFirmwareOSInterface,
qemuFirmwareOSInterfaceFr
static void
-qemuFirmwareFlashFileFreeContent(qemuFirmwareFlashFile flash)
+qemuFirmwareFlashFileFreeContent(qemuFirmwareFlashFilePtr flash)
{
- VIR_FREE(flash.filename);
- VIR_FREE(flash.format);
+ VIR_FREE(flash->filename);
+ VIR_FREE(flash->format);
}
static void
-qemuFirmwareMappingFlashFreeContent(qemuFirmwareMappingFlash flash)
+qemuFirmwareMappingFlashFreeContent(qemuFirmwareMappingFlashPtr flash)
{
- qemuFirmwareFlashFileFreeContent(flash.executable);
- qemuFirmwareFlashFileFreeContent(flash.nvram_template);
+ qemuFirmwareFlashFileFreeContent(&flash->executable);
+ qemuFirmwareFlashFileFreeContent(&flash->nvram_template);
}
static void
-qemuFirmwareMappingKernelFreeContent(qemuFirmwareMappingKernel kernel)
+qemuFirmwareMappingKernelFreeContent(qemuFirmwareMappingKernelPtr kernel)
{
- VIR_FREE(kernel.filename);
+ VIR_FREE(kernel->filename);
}
static void
-qemuFirmwareMappingMemoryFreeContent(qemuFirmwareMappingMemory memory)
+qemuFirmwareMappingMemoryFreeContent(qemuFirmwareMappingMemoryPtr memory)
{
- VIR_FREE(memory.filename);
+ VIR_FREE(memory->filename);
}
static void
-qemuFirmwareMappingFreeContent(qemuFirmwareMapping mapping)
+qemuFirmwareMappingFreeContent(qemuFirmwareMappingPtr mapping)
{
- switch (mapping.device) {
+ switch (mapping->device) {
case QEMU_FIRMWARE_DEVICE_FLASH:
- qemuFirmwareMappingFlashFreeContent(mapping.data.flash);
+ qemuFirmwareMappingFlashFreeContent(&mapping->data.flash);
break;
case QEMU_FIRMWARE_DEVICE_KERNEL:
- qemuFirmwareMappingKernelFreeContent(mapping.data.kernel);
+ qemuFirmwareMappingKernelFreeContent(&mapping->data.kernel);
break;
case QEMU_FIRMWARE_DEVICE_MEMORY:
- qemuFirmwareMappingMemoryFreeContent(mapping.data.memory);
+ qemuFirmwareMappingMemoryFreeContent(&mapping->data.memory);
break;
case QEMU_FIRMWARE_DEVICE_NONE:
case QEMU_FIRMWARE_DEVICE_LAST:
@@ -271,7 +271,7 @@ qemuFirmwareFree(qemuFirmwarePtr fw)
return;
qemuFirmwareOSInterfaceFree(fw->interfaces);
- qemuFirmwareMappingFreeContent(fw->mapping);
+ qemuFirmwareMappingFreeContent(&fw->mapping);
for (i = 0; i < fw->ntargets; i++)
qemuFirmwareTargetFree(fw->targets[i]);
g_free(fw->targets);
--
2.29.2