Add ftdi_eeprom_free() to free allocated memory in eeprom
authorWilfried Holzke <libftdi@holzke.net>
Mon, 14 Jun 2010 07:20:14 +0000 (09:20 +0200)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Mon, 14 Jun 2010 07:21:03 +0000 (09:21 +0200)
AUTHORS
src/ftdi.c
src/ftdi.h

diff --git a/AUTHORS b/AUTHORS
index 506ff18..9aed93e 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -38,3 +38,4 @@ see Changelog for full details:
   Thomas Fischl <fischl@fundf.net>
   Tim Ansell <mithro@mithis.com>
   Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
+  Wilfried Holzke <libftdi@holzke.net>
index b977b77..7f7e5a0 100644 (file)
@@ -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().
 
index e7c2268..aaa7744 100644 (file)
@@ -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);