From 95ac1ca2f571a87170fa5578412ef5cb64a941e0 Mon Sep 17 00:00:00 2001 From: Wilfried Holzke Date: Mon, 14 Jun 2010 09:20:14 +0200 Subject: [PATCH] Add ftdi_eeprom_free() to free allocated memory in eeprom --- AUTHORS | 1 + src/ftdi.c | 21 +++++++++++++++++++++ src/ftdi.h | 1 + 3 files changed, 23 insertions(+), 0 deletions(-) diff --git a/AUTHORS b/AUTHORS index 506ff18..9aed93e 100644 --- a/AUTHORS +++ b/AUTHORS @@ -38,3 +38,4 @@ see Changelog for full details: Thomas Fischl Tim Ansell Uwe Bonnes + Wilfried Holzke diff --git a/src/ftdi.c b/src/ftdi.c index b977b77..7f7e5a0 100644 --- a/src/ftdi.c +++ b/src/ftdi.c @@ -2205,6 +2205,27 @@ void ftdi_eeprom_initdefaults(struct ftdi_eeprom *eeprom) } /** + Frees allocated memory in eeprom. + + \param eeprom Pointer to ftdi_eeprom +*/ +void ftdi_eeprom_free(struct ftdi_eeprom *eeprom) +{ + if (eeprom->manufacturer != 0) { + free(eeprom->manufacturer); + eeprom->manufacturer = 0; + } + if (eeprom->product != 0) { + free(eeprom->product); + eeprom->product = 0; + } + if (eeprom->serial != 0) { + free(eeprom->serial); + eeprom->serial = 0; + } +} + +/** Build binary output from ftdi_eeprom structure. Output is suitable for ftdi_write_eeprom(). diff --git a/src/ftdi.h b/src/ftdi.h index e7c2268..aaa7744 100644 --- a/src/ftdi.h +++ b/src/ftdi.h @@ -384,6 +384,7 @@ extern "C" /* init and build eeprom from ftdi_eeprom structure */ void ftdi_eeprom_initdefaults(struct ftdi_eeprom *eeprom); + void ftdi_eeprom_free(struct ftdi_eeprom *eeprom); int ftdi_eeprom_build(struct ftdi_eeprom *eeprom, unsigned char *output); int ftdi_eeprom_decode(struct ftdi_eeprom *eeprom, unsigned char *output, int size); -- 1.7.1