diff mbox

[3/3] hw/spitz: Fix memory leaks (detected by Valgrind)

Message ID 1348513730-7485-4-git-send-email-sw@weilnetz.de
State New
Headers show

Commit Message

Stefan Weil Sept. 24, 2012, 7:08 p.m. UTC
outsignals was allocated using g_malloc and never released.
It is not necessary to use dynamic memory allocation
for that array because its entries are copied
and not used otherwise. Only 7 entries are used.

lcd_hsync can be initialized directly instead of copying the first entry
of a dynamically allocated array which is never released.

Cc: Andrzej Zaborowski <balrogg@gmail.com>
Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 hw/spitz.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/hw/spitz.c b/hw/spitz.c
index 20e7835..90dc35b 100644
--- a/hw/spitz.c
+++ b/hw/spitz.c
@@ -798,7 +798,8 @@  static void spitz_out_switch(void *opaque, int line, int level)
 static void spitz_scoop_gpio_setup(PXA2xxState *cpu,
                 DeviceState *scp0, DeviceState *scp1)
 {
-    qemu_irq *outsignals = qemu_allocate_irqs(spitz_out_switch, cpu, 8);
+    qemu_irq outsignals[7];
+    qemu_init_irqs(spitz_out_switch, cpu, outsignals, ARRAY_SIZE(outsignals));
 
     qdev_connect_gpio_out(scp0, SPITZ_SCP_CHRG_ON, outsignals[0]);
     qdev_connect_gpio_out(scp0, SPITZ_SCP_JK_B, outsignals[1]);
@@ -842,7 +843,7 @@  static void spitz_gpio_setup(PXA2xxState *cpu, int slots)
      * wouldn't guarantee that a guest ever exits the loop.
      */
     spitz_hsync = 0;
-    lcd_hsync = qemu_allocate_irqs(spitz_lcd_hsync_handler, cpu, 1)[0];
+    qemu_init_irqs(spitz_lcd_hsync_handler, cpu, &lcd_hsync, 1);
     pxa2xx_gpio_read_notifier(cpu->gpio, lcd_hsync);
     pxa2xx_lcd_vsync_notifier(cpu->lcd, lcd_hsync);