From f7baf8c57b19b791863c1e9bb6e59c967ddd4871 Mon Sep 17 00:00:00 2001 From: Michel Pollet Date: Thu, 2 Sep 2010 12:55:40 +0100 Subject: [PATCH] eeprom: Added a dealloc function frees the eeprom memory at teardown time Signed-off-by: Michel Pollet --- simavr/sim/avr_eeprom.c | 9 +++++++++ 1 file changed, 9 insertions(+) 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) -- 2.39.5