Commit f7baf8c57b19b791863c1e9bb6e59c967ddd4871
authorMichel Pollet <buserror@gmail.com>
Thu, 2 Sep 2010 11:55:40 +0000 (12:55 +0100)
committerMichel Pollet <buserror@gmail.com>
Thu, 2 Sep 2010 11:55:40 +0000 (12:55 +0100)
frees the eeprom memory at teardown time

Signed-off-by: Michel Pollet <buserror@gmail.com>
simavr/sim/avr_eeprom.c

index 60043eed85e68b5efa512113d4587bc034b00408..eccedbe7c495c0455abfe059f4a0b4d6cdf3bde0 100644 (file)
@@ -113,9 +113,18 @@ static int avr_eeprom_ioctl(struct avr_io_t * port, uint32_t ctl, void * io_para
        return res;
 }
 
+static void avr_eeprom_dealloc(struct avr_io_t * port)
+{
+       avr_eeprom_t * p = (avr_eeprom_t *)port;
+       if (p->eeprom)
+               free(p->eeprom);
+       p->eeprom = NULL;
+}
+
 static avr_io_t        _io = {
        .kind = "eeprom",
        .ioctl = avr_eeprom_ioctl,
+       .dealloc = avr_eeprom_dealloc,
 };
 
 void avr_eeprom_init(avr_t * avr, avr_eeprom_t * p)