Remove TRYFREE macro from minizip.

This commit is contained in:
Mark Adler 2023-08-13 17:43:36 -07:00
parent c97a8f1e67
commit 384e50eea4
2 changed files with 19 additions and 25 deletions

View File

@ -111,9 +111,6 @@
#ifndef ALLOC #ifndef ALLOC
# define ALLOC(size) (malloc(size)) # define ALLOC(size) (malloc(size))
#endif #endif
#ifndef TRYFREE
# define TRYFREE(p) { free(p);}
#endif
#define SIZECENTRALDIRITEM (0x2e) #define SIZECENTRALDIRITEM (0x2e)
#define SIZEZIPLOCALHEADER (0x1e) #define SIZEZIPLOCALHEADER (0x1e)
@ -380,7 +377,7 @@ local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_f
if (uPosFound!=CENTRALDIRINVALID) if (uPosFound!=CENTRALDIRINVALID)
break; break;
} }
TRYFREE(buf); free(buf);
return uPosFound; return uPosFound;
} }
@ -443,7 +440,7 @@ local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
if (uPosFound!=CENTRALDIRINVALID) if (uPosFound!=CENTRALDIRINVALID)
break; break;
} }
TRYFREE(buf); free(buf);
if (uPosFound == CENTRALDIRINVALID) if (uPosFound == CENTRALDIRINVALID)
return CENTRALDIRINVALID; return CENTRALDIRINVALID;
@ -723,7 +720,7 @@ extern int ZEXPORT unzClose(unzFile file) {
unzCloseCurrentFile(file); unzCloseCurrentFile(file);
ZCLOSE64(s->z_filefunc, s->filestream); ZCLOSE64(s->z_filefunc, s->filestream);
TRYFREE(s); free(s);
return UNZ_OK; return UNZ_OK;
} }
@ -1384,7 +1381,7 @@ extern int ZEXPORT unzOpenCurrentFile3(unzFile file, int* method,
if (pfile_in_zip_read_info->read_buffer==NULL) if (pfile_in_zip_read_info->read_buffer==NULL)
{ {
TRYFREE(pfile_in_zip_read_info); free(pfile_in_zip_read_info);
return UNZ_INTERNALERROR; return UNZ_INTERNALERROR;
} }
@ -1441,8 +1438,8 @@ extern int ZEXPORT unzOpenCurrentFile3(unzFile file, int* method,
pfile_in_zip_read_info->stream_initialised=Z_BZIP2ED; pfile_in_zip_read_info->stream_initialised=Z_BZIP2ED;
else else
{ {
TRYFREE(pfile_in_zip_read_info->read_buffer); free(pfile_in_zip_read_info->read_buffer);
TRYFREE(pfile_in_zip_read_info); free(pfile_in_zip_read_info);
return err; return err;
} }
#else #else
@ -1462,8 +1459,8 @@ extern int ZEXPORT unzOpenCurrentFile3(unzFile file, int* method,
pfile_in_zip_read_info->stream_initialised=Z_DEFLATED; pfile_in_zip_read_info->stream_initialised=Z_DEFLATED;
else else
{ {
TRYFREE(pfile_in_zip_read_info->read_buffer); free(pfile_in_zip_read_info->read_buffer);
TRYFREE(pfile_in_zip_read_info); free(pfile_in_zip_read_info);
return err; return err;
} }
/* windowBits is passed < 0 to tell that there is no zlib header. /* windowBits is passed < 0 to tell that there is no zlib header.
@ -1894,7 +1891,7 @@ extern int ZEXPORT unzCloseCurrentFile(unzFile file) {
} }
TRYFREE(pfile_in_zip_read_info->read_buffer); free(pfile_in_zip_read_info->read_buffer);
pfile_in_zip_read_info->read_buffer = NULL; pfile_in_zip_read_info->read_buffer = NULL;
if (pfile_in_zip_read_info->stream_initialised == Z_DEFLATED) if (pfile_in_zip_read_info->stream_initialised == Z_DEFLATED)
inflateEnd(&pfile_in_zip_read_info->stream); inflateEnd(&pfile_in_zip_read_info->stream);
@ -1905,7 +1902,7 @@ extern int ZEXPORT unzCloseCurrentFile(unzFile file) {
pfile_in_zip_read_info->stream_initialised = 0; pfile_in_zip_read_info->stream_initialised = 0;
TRYFREE(pfile_in_zip_read_info); free(pfile_in_zip_read_info);
s->pfile_in_zip_read=NULL; s->pfile_in_zip_read=NULL;

View File

@ -62,9 +62,6 @@
#ifndef ALLOC #ifndef ALLOC
# define ALLOC(size) (malloc(size)) # define ALLOC(size) (malloc(size))
#endif #endif
#ifndef TRYFREE
# define TRYFREE(p) {if (p) free(p);}
#endif
/* /*
#define SIZECENTRALDIRITEM (0x2e) #define SIZECENTRALDIRITEM (0x2e)
@ -204,7 +201,7 @@ local void free_datablock(linkedlist_datablock_internal* ldi) {
while (ldi!=NULL) while (ldi!=NULL)
{ {
linkedlist_datablock_internal* ldinext = ldi->next_datablock; linkedlist_datablock_internal* ldinext = ldi->next_datablock;
TRYFREE(ldi); free(ldi);
ldi = ldinext; ldi = ldinext;
} }
} }
@ -505,7 +502,7 @@ local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_f
if (uPosFound!=0) if (uPosFound!=0)
break; break;
} }
TRYFREE(buf); free(buf);
return uPosFound; return uPosFound;
} }
@ -568,7 +565,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
break; break;
} }
TRYFREE(buf); free(buf);
if (uPosFound == 0) if (uPosFound == 0)
return 0; return 0;
@ -802,7 +799,7 @@ local int LoadCentralDirectoryRecord(zip64_internal* pziinit) {
size_central_dir_to_read-=read_this; size_central_dir_to_read-=read_this;
} }
TRYFREE(buf_read); free(buf_read);
} }
pziinit->begin_pos = byte_before_the_zipfile; pziinit->begin_pos = byte_before_the_zipfile;
pziinit->number_entry = number_entry_CD; pziinit->number_entry = number_entry_CD;
@ -876,9 +873,9 @@ extern zipFile ZEXPORT zipOpen3(const void *pathname, int append, zipcharpc* glo
if (err != ZIP_OK) if (err != ZIP_OK)
{ {
# ifndef NO_ADDFILEINEXISTINGZIP # ifndef NO_ADDFILEINEXISTINGZIP
TRYFREE(ziinit.globalcomment); free(ziinit.globalcomment);
# endif /* !NO_ADDFILEINEXISTINGZIP*/ # endif /* !NO_ADDFILEINEXISTINGZIP*/
TRYFREE(zi); free(zi);
return NULL; return NULL;
} }
else else
@ -1885,9 +1882,9 @@ extern int ZEXPORT zipClose(zipFile file, const char* global_comment) {
err = ZIP_ERRNO; err = ZIP_ERRNO;
#ifndef NO_ADDFILEINEXISTINGZIP #ifndef NO_ADDFILEINEXISTINGZIP
TRYFREE(zi->globalcomment); free(zi->globalcomment);
#endif #endif
TRYFREE(zi); free(zi);
return err; return err;
} }
@ -1944,7 +1941,7 @@ extern int ZEXPORT zipRemoveExtraInfoBlock(char* pData, int* dataLen, short sHea
else else
retVal = ZIP_ERRNO; retVal = ZIP_ERRNO;
TRYFREE(pNewHeader); free(pNewHeader);
return retVal; return retVal;
} }