From: Michel Pollet Date: Thu, 2 Sep 2010 11:55:40 +0000 (+0100) Subject: eeprom: Added a dealloc function X-Git-Tag: v1.0a6~13 X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=f7baf8c57b19b791863c1e9bb6e59c967ddd4871;p=sx%2Fsimavr.git eeprom: Added a dealloc function frees the eeprom memory at teardown time Signed-off-by: Michel Pollet --- diff --git a/simavr/sim/avr_eeprom.c b/simavr/sim/avr_eeprom.c index 60043ee..eccedbe 100644 --- a/simavr/sim/avr_eeprom.c +++ b/simavr/sim/avr_eeprom.c @@ -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)