From: Thomas Jarosch Date: Fri, 9 Sep 2011 09:45:10 +0000 (+0200) Subject: Merge branch 'new-baudrate-code' X-Git-Tag: v1.0rc1~71 X-Git-Url: http://developer.intra2net.com/git/?p=libftdi;a=commitdiff_plain;h=f9df39f525b9ffebb43bd5a0cfca998f681aed02;hp=3c9ef8f8c6951ac8245b3b6c6eb98758fe06ec4e Merge branch 'new-baudrate-code' --- diff --git a/ftdi_eeprom/example.conf b/ftdi_eeprom/example.conf index cfc9fc3..2c50fda 100644 --- a/ftdi_eeprom/example.conf +++ b/ftdi_eeprom/example.conf @@ -18,7 +18,6 @@ remote_wakeup=false # Turn this on for remote wakeup feature use_serial=true # Use the serial number string # Normally out don't have to change one of these flags -BM_type_chip=true # Newer chips are all BM type in_is_isochronous=false # In Endpoint is Isochronous out_is_isochronous=false # Out Endpoint is Isochronous suspend_pull_downs=false # Enable suspend pull downs for lower power diff --git a/ftdi_eeprom/main.c b/ftdi_eeprom/main.c index df7c877..b33266f 100644 --- a/ftdi_eeprom/main.c +++ b/ftdi_eeprom/main.c @@ -145,7 +145,7 @@ int main(int argc, char *argv[]) int _read = 0, _erase = 0, _flash = 0; int my_eeprom_size = 0; - unsigned char eeprom_buf[FTDI_MAX_EEPROM_SIZE]; + unsigned char *eeprom_buf = NULL; char *filename; int size_check; int i, argc_filename; @@ -264,9 +264,16 @@ int main(int argc, char *argv[]) printf("serial = \"%s\"\n", eeprom->serial); */ + eeprom_buf = malloc(my_eeprom_size); + ftdi_get_eeprom_buf(ftdi, eeprom_buf, my_eeprom_size); + + if (eeprom_buf == NULL) + { + fprintf(stderr, "Malloc failed, aborting\n"); + goto cleanup; + } if (filename != NULL && strlen(filename) > 0) { - ftdi_get_eeprom_buf(ftdi, eeprom_buf, my_eeprom_size); FILE *fp = fopen (filename, "wb"); fwrite (eeprom_buf, 1, my_eeprom_size, fp); @@ -368,12 +375,15 @@ int main(int argc, char *argv[]) } cleanup: + if (eeprom_buf) + free(eeprom_buf); if (_read > 0 || _erase > 0 || _flash > 0) { printf("FTDI close: %d\n", ftdi_usb_close(ftdi)); } ftdi_deinit (ftdi); + ftdi_free (ftdi); cfg_free(cfg);