diff options
Diffstat (limited to 'ext/zip/lib/zip_discard.c')
-rw-r--r-- | ext/zip/lib/zip_discard.c | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/ext/zip/lib/zip_discard.c b/ext/zip/lib/zip_discard.c index 5b36df8b0b..db22370842 100644 --- a/ext/zip/lib/zip_discard.c +++ b/ext/zip/lib/zip_discard.c @@ -1,6 +1,6 @@ /* zip_discard.c -- discard and free struct zip - Copyright (C) 1999-2012 Dieter Baron and Thomas Klausner + Copyright (C) 1999-2014 Dieter Baron and Thomas Klausner This file is part of libzip, a library to manipulate ZIP archives. The authors can be contacted at <libzip@nih.at> @@ -17,7 +17,7 @@ 3. The names of the authors may not be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -32,30 +32,27 @@ */ - #include <stdlib.h> #include "zipint.h" - /* zip_discard: frees the space allocated to a zipfile struct, and closes the corresponding file. */ void -zip_discard(struct zip *za) +zip_discard(zip_t *za) { zip_uint64_t i; if (za == NULL) return; - if (za->zn) - free(za->zn); - - if (za->zp) - fclose(za->zp); + if (za->src) { + zip_source_close(za->src); + zip_source_free(za->src); + } free(za->default_password); _zip_string_free(za->comment_orig); @@ -67,16 +64,13 @@ zip_discard(struct zip *za) free(za->entry); } - for (i=0; i<za->nfile; i++) { - if (za->file[i]->error.zip_err == ZIP_ER_OK) { - _zip_error_set(&za->file[i]->error, ZIP_ER_ZIPCLOSED, 0); - za->file[i]->za = NULL; - } + for (i=0; i<za->nopen_source; i++) { + _zip_source_invalidate(za->open_source[i]); } + free(za->open_source); - _zip_error_fini(&za->error); - free(za->file); - + zip_error_fini(&za->error); + free(za); return; |