Revert "clang-format"

This reverts commit 046a374bf0f03ec9e00b7717409864cd610f7764.
This commit is contained in:
Kuba Podgórski 2020-08-18 12:29:18 +02:00
parent 046a374bf0
commit ce1a404443
3 changed files with 16 additions and 19 deletions

View File

@ -833,8 +833,7 @@ int zip_create(const char *zipname, const char *filenames[], size_t len) {
} }
static inline int extract(mz_zip_archive *zip_archive, const char *dir, static inline int extract(mz_zip_archive *zip_archive, const char *dir,
int (*on_extract)(const char *filename, void *arg), int (*on_extract)(const char *filename, void *arg), void *arg){
void *arg) {
int status = -1; int status = -1;
mz_uint i, n; mz_uint i, n;
char path[MAX_PATH + 1]; char path[MAX_PATH + 1];
@ -940,13 +939,13 @@ out:
status = -1; status = -1;
} }
return status; return status;
} }
static inline mz_zip_archive *zip_archive_init_file(const char *zipname, static inline mz_zip_archive * zip_archive_init_file(const char *zipname, mz_uint32 flags){
mz_uint32 flags) {
mz_zip_archive *zip_archive = NULL; mz_zip_archive *zip_archive = NULL;
zip_archive = (mz_zip_archive *)malloc(sizeof(mz_zip_archive)); zip_archive = (mz_zip_archive *)malloc(sizeof(mz_zip_archive));
if (!zip_archive) { if (!zip_archive){
// malloc failed. // malloc failed.
return NULL; return NULL;
} }
@ -965,14 +964,14 @@ static inline mz_zip_archive *zip_archive_init_file(const char *zipname,
} }
int zip_extract(const char *zipname, const char *dir, int zip_extract(const char *zipname, const char *dir,
int (*on_extract)(const char *filename, void *arg), void *arg) { int (*on_extract)(const char *filename, void *arg), void *arg) {
if (!zipname || !dir) { if (!zipname || !dir) {
// Cannot parse zip archive name // Cannot parse zip archive name
return -1; return -1;
} }
// init zip_archive and set reader // init zip_archive and set reader
mz_zip_archive *zip_archive = zip_archive_init_file(zipname, 0); mz_zip_archive *zip_archive = zip_archive_init_file(zipname, 0);
if (!zip_archive) { if (!zip_archive){
return -1; return -1;
} }
@ -983,11 +982,11 @@ int zip_extract(const char *zipname, const char *dir,
return status; return status;
} }
static inline mz_zip_archive * static inline mz_zip_archive * zip_archive_init_mem(const void *stream,
zip_archive_init_mem(const void *stream, size_t size, mz_uint32 flags) { size_t size, mz_uint32 flags){
mz_zip_archive *zip_archive = NULL; mz_zip_archive *zip_archive = NULL;
zip_archive = (mz_zip_archive *)malloc(sizeof(mz_zip_archive)); zip_archive = (mz_zip_archive *)malloc(sizeof(mz_zip_archive));
if (!zip_archive) { if (!zip_archive){
// malloc failed. // malloc failed.
return NULL; return NULL;
} }
@ -1006,15 +1005,14 @@ zip_archive_init_mem(const void *stream, size_t size, mz_uint32 flags) {
} }
int zip_extract_stream(const char *stream, size_t size, const char *dir, int zip_extract_stream(const char *stream, size_t size, const char *dir,
int (*on_extract)(const char *filename, void *arg), int (*on_extract)(const char *filename, void *arg), void *arg) {
void *arg) {
if (!stream || !dir) { if (!stream || !dir) {
// Cannot parse zip archive stream // Cannot parse zip archive stream
return -1; return -1;
} }
// init zip_archive and set reader // init zip_archive and set reader
mz_zip_archive *zip_archive = zip_archive_init_mem(stream, size, 0); mz_zip_archive *zip_archive = zip_archive_init_mem(stream, size, 0);
if (!zip_archive) { if (!zip_archive){
return -1; return -1;
} }
@ -1023,4 +1021,5 @@ int zip_extract_stream(const char *stream, size_t size, const char *dir,
free(zip_archive); free(zip_archive);
return status; return status;
}
}

View File

@ -331,9 +331,7 @@ extern int zip_extract(const char *zipname, const char *dir,
* @return the return code - 0 on success, negative number (< 0) on error. * @return the return code - 0 on success, negative number (< 0) on error.
*/ */
extern int zip_extract_stream(const char *stream, size_t size, const char *dir, extern int zip_extract_stream(const char *stream, size_t size, const char *dir,
int (*on_extract)(const char *filename, int (*on_extract)(const char *filename, void *arg), void *arg);
void *arg),
void *arg);
/** @} */ /** @} */
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -462,7 +462,7 @@ static void test_unix_permissions(void) {
remove(RFILE); remove(RFILE);
remove(ZIPNAME); remove(ZIPNAME);
#endif #endif
} }
static void test_extract_stream(void) { static void test_extract_stream(void) {
@ -482,7 +482,7 @@ static void test_extract_stream(void) {
FILE *fp = NULL; FILE *fp = NULL;
fp = fopen(ZIPNAME, "r+"); fp = fopen(ZIPNAME, "r+");
assert(fp != NULL); assert(fp != NULL);
fseek(fp, 0L, SEEK_END); fseek(fp, 0L, SEEK_END);
size_t filesize = ftell(fp); size_t filesize = ftell(fp);
fseek(fp, 0L, SEEK_SET); fseek(fp, 0L, SEEK_SET);