mirror of
https://github.com/zlib-ng/minizip-ng
synced 2026-08-25 14:26:08 -04:00
Remove first param from create functions.
Better handle low memory situations.
This commit is contained in:
parent
3da04514cd
commit
217adc9363
49 changed files with 484 additions and 455 deletions
25
minizip.c
25
minizip.c
|
|
@ -105,7 +105,10 @@ int32_t minizip_list(const char *path) {
|
|||
void *reader = NULL;
|
||||
|
||||
|
||||
mz_zip_reader_create(&reader);
|
||||
reader = mz_zip_reader_create();
|
||||
if (!reader)
|
||||
return MZ_MEM_ERROR;
|
||||
|
||||
err = mz_zip_reader_open_file(reader, path);
|
||||
if (err != MZ_OK) {
|
||||
printf("Error %" PRId32 " opening archive %s\n", err, path);
|
||||
|
|
@ -244,7 +247,10 @@ int32_t minizip_add(const char *path, const char *password, minizip_opt *options
|
|||
printf("Archive %s\n", path);
|
||||
|
||||
/* Create zip writer */
|
||||
mz_zip_writer_create(&writer);
|
||||
writer = mz_zip_writer_create();
|
||||
if (!writer)
|
||||
return MZ_MEM_ERROR;
|
||||
|
||||
mz_zip_writer_set_password(writer, password);
|
||||
mz_zip_writer_set_aes(writer, options->aes);
|
||||
mz_zip_writer_set_compress_method(writer, options->compress_method);
|
||||
|
|
@ -353,7 +359,10 @@ int32_t minizip_extract(const char *path, const char *pattern, const char *desti
|
|||
printf("Archive %s\n", path);
|
||||
|
||||
/* Create zip reader */
|
||||
mz_zip_reader_create(&reader);
|
||||
reader = mz_zip_reader_create();
|
||||
if (!reader)
|
||||
return MZ_MEM_ERROR;
|
||||
|
||||
mz_zip_reader_set_pattern(reader, pattern, 1);
|
||||
mz_zip_reader_set_password(reader, password);
|
||||
mz_zip_reader_set_encoding(reader, options->encoding);
|
||||
|
|
@ -414,8 +423,14 @@ int32_t minizip_erase(const char *src_path, const char *target_path, int32_t arg
|
|||
target_path_ptr = tmp_path;
|
||||
}
|
||||
|
||||
mz_zip_reader_create(&reader);
|
||||
mz_zip_writer_create(&writer);
|
||||
reader = mz_zip_reader_create();
|
||||
if (!reader)
|
||||
return MZ_MEM_ERROR;
|
||||
writer = mz_zip_writer_create();
|
||||
if (!writer) {
|
||||
mz_zip_reader_delete(&reader);
|
||||
return MZ_MEM_ERROR;
|
||||
}
|
||||
|
||||
/* Open original archive we want to erase an entry in */
|
||||
err = mz_zip_reader_open_file(reader, src_path);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue