diff options
author | mifi <mifi@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2007-12-18 21:20:28 +0000 |
---|---|---|
committer | mifi <mifi@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2007-12-18 21:20:28 +0000 |
commit | 02f3765351c9e25185b745b84f1a2604fb2149c7 (patch) | |
tree | 81331db01e68baf67bc2cc271b1f1ed2a6962d76 /src/helper | |
parent | ed1e9d6abdece4fbf6251a11f0eca3c921221048 (diff) | |
download | openocd+libswd-02f3765351c9e25185b745b84f1a2604fb2149c7.tar.gz openocd+libswd-02f3765351c9e25185b745b84f1a2604fb2149c7.tar.bz2 openocd+libswd-02f3765351c9e25185b745b84f1a2604fb2149c7.tar.xz openocd+libswd-02f3765351c9e25185b745b84f1a2604fb2149c7.zip |
- added patch for new flash functionality like:
flash verify_image and flash erase_address.
- added patch for new parport_write_on_exit command.
Even this patch will fix some memory leaks.
(thanks too oyvind and Spen for these patches)
git-svn-id: svn://svn.berlios.de/openocd/trunk@240 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/helper')
-rw-r--r-- | src/helper/command.c | 1 | ||||
-rw-r--r-- | src/helper/fileio.c | 12 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/helper/command.c b/src/helper/command.c index f69deb49..44ead7cb 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -506,6 +506,7 @@ command_context_t* copy_command_context(command_context_t* context) int command_done(command_context_t *context) { free(context); + context = NULL; return ERROR_OK; } diff --git a/src/helper/fileio.c b/src/helper/fileio.c index 3ee0b18b..f98d634f 100644 --- a/src/helper/fileio.c +++ b/src/helper/fileio.c @@ -44,8 +44,6 @@ int fileio_open_local(fileio_t *fileio) fileio_local_t *fileio_local = malloc(sizeof(fileio_local_t)); char access[4]; - fileio->location_private = fileio_local; - if ((fileio->access != FILEIO_WRITE) && (fileio->access != FILEIO_READWRITE)) { if (stat(fileio->url, &fileio_local->file_stat) == -1) @@ -113,6 +111,8 @@ int fileio_open_local(fileio_t *fileio) return ERROR_FILEIO_OPERATION_FAILED; } + fileio->location_private = fileio_local; + if ((fileio->access != FILEIO_WRITE) || (fileio->access == FILEIO_READWRITE)) { fileio->size = fileio_local->file_stat.st_size; @@ -172,6 +172,12 @@ int fileio_close_local(fileio_t *fileio) int retval; fileio_local_t *fileio_local = fileio->location_private; + if (fileio->location_private == NULL) + { + snprintf(fileio->error_str, FILEIO_MAX_ERROR_STRING, "couldn't close %s: ", fileio->url); + return ERROR_FILEIO_OPERATION_FAILED; + } + if ((retval = fclose(fileio_local->file)) != 0) { if (retval == EBADF) @@ -187,6 +193,7 @@ int fileio_close_local(fileio_t *fileio) } free(fileio->location_private); + fileio->location_private = NULL; return ERROR_OK; } @@ -209,6 +216,7 @@ int fileio_close(fileio_t *fileio) return retval; free(fileio->url); + fileio->url = NULL; return ERROR_OK; } |