List Archive
Thread
-
[PATCH 0/3] libzip does not use EOCD nentry field ,
Jay Freeman (saurik)
(2016/08/16 09:13:31)
- [PATCH 2/3] Have _zip_add_entry work on zip_array_, Jay Freeman (saurik) (2016/08/16 09:10:55)
- [PATCH 3/3] Support zip files with >0xffff entries, Jay Freeman (saurik) (2016/08/16 09:11:35)
- [PATCH 1/3] Use zip_array_t to unify zip_t and zip, Jay Freeman (saurik) (2016/08/16 09:11:35)
- Re: [PATCH 0/3] libzip does not use EOCD nentry fi, Martin Buchholz (2016/08/16 15:46:07)
Message
--- lib/zip_add_entry.c | 22 +++++++++++----------- lib/zip_file_replace.c | 2 +- lib/zipint.h | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/zip_add_entry.c b/lib/zip_add_entry.c index 721fdef..577a324 100644 --- a/lib/zip_add_entry.c +++ b/lib/zip_add_entry.c @@ -40,13 +40,13 @@ /* NOTE: Signed due to -1 on error. See zip_add.c for more details. */ zip_int64_t -_zip_add_entry(zip_t *za) +_zip_add_entry(zip_array_t *ea, zip_error_t *error) { zip_uint64_t idx; - if (za->entries.nentry+1 >= za->entries.nentry_alloc) { + if (ea->nentry+1 >= ea->nentry_alloc) { zip_entry_t *rentries; - zip_uint64_t nalloc = za->entries.nentry_alloc; + zip_uint64_t nalloc = ea->nentry_alloc; zip_uint64_t additional_entries = 2 * nalloc; zip_uint64_t realloc_size; @@ -60,22 +60,22 @@ _zip_add_entry(zip_t *za) nalloc += additional_entries; realloc_size = sizeof(struct zip_entry) * (size_t)nalloc; - if (sizeof(struct zip_entry) * (size_t)za->entries.nentry_alloc > realloc_size) { - zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + if (sizeof(struct zip_entry) * (size_t)ea->nentry_alloc > realloc_size) { + zip_error_set(error, ZIP_ER_MEMORY, 0); return -1; } - rentries = (zip_entry_t *)realloc(za->entries.entry, sizeof(struct zip_entry) * (size_t)nalloc); + rentries = (zip_entry_t *)realloc(ea->entry, sizeof(struct zip_entry) * (size_t)nalloc); if (!rentries) { - zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + zip_error_set(error, ZIP_ER_MEMORY, 0); return -1; } - za->entries.entry = rentries; - za->entries.nentry_alloc = nalloc; + ea->entry = rentries; + ea->nentry_alloc = nalloc; } - idx = za->entries.nentry++; + idx = ea->nentry++; - _zip_entry_init(za->entries.entry+idx); + _zip_entry_init(ea->entry+idx); return (zip_int64_t)idx; } diff --git a/lib/zip_file_replace.c b/lib/zip_file_replace.c index 702877e..54b8177 100644 --- a/lib/zip_file_replace.c +++ b/lib/zip_file_replace.c @@ -72,7 +72,7 @@ _zip_file_replace(zip_t *za, zip_uint64_t idx, const char *name, zip_source_t *s if (i == -1) { /* create and use new entry, used by zip_add */ - if ((i=_zip_add_entry(za)) < 0) + if ((i=_zip_add_entry(&za->entries, &za->error)) < 0) return -1; } idx = (zip_uint64_t)i; diff --git a/lib/zipint.h b/lib/zipint.h index 5d8f425..59f0e9c 100644 --- a/lib/zipint.h +++ b/lib/zipint.h @@ -343,7 +343,7 @@ extern const int _zip_err_type[]; #define ZIP_IS_RDONLY(za) ((za)->ch_flags & ZIP_AFL_RDONLY) -zip_int64_t _zip_add_entry(zip_t *); +zip_int64_t _zip_add_entry(zip_array_t *, zip_error_t *error); zip_uint8_t *_zip_buffer_data(zip_buffer_t *buffer); bool _zip_buffer_eof(zip_buffer_t *buffer); -- 2.6.3
Made by MHonArc.