Removed dead stores; fixed minor memory leak

This commit is contained in:
Gianluca Bertani
2013-06-23 00:58:23 +02:00
parent 5efa1efdb1
commit bc9cedb8e8
2 changed files with 31 additions and 30 deletions
+24 -24
View File
@@ -123,8 +123,8 @@
#ifndef UNZ_BUFSIZE
#define UNZ_BUFSIZE (64 * 1024)
#endif
#ifndef UNZ_MAXFILENAMEINZIP
#define UNZ_MAXFILENAMEINZIP (256)
#ifndef UNZ_MAXFILENAMEINZIP
#define UNZ_MAXFILENAMEINZIP (256)
#endif
#ifndef ALLOC
@@ -965,7 +965,7 @@ local int unz64local_GetCurrentFileInfoInternal(unzFile file, unz_file_info64 *p
if (lSeek != 0)
{
if (ZSEEK64(s->z_filefunc, s->filestream_with_CD, lSeek, ZLIB_FILEFUNC_SEEK_CUR) == 0)
lSeek=0;
/* lSeek=0 */ ;
else
err = UNZ_ERRNO;
}
@@ -973,10 +973,10 @@ local int unz64local_GetCurrentFileInfoInternal(unzFile file, unz_file_info64 *p
if ((file_info.size_file_comment > 0) && (comment_size > 0))
if (ZREAD64(s->z_filefunc, s->filestream_with_CD, comment, (uLong)bytes_to_read) != bytes_to_read)
err = UNZ_ERRNO;
lSeek += file_info.size_file_comment - (uLong)bytes_to_read;
/* lSeek += file_info.size_file_comment - (uLong)bytes_to_read */ ;
}
else
lSeek += file_info.size_file_comment;
/* lSeek += file_info.size_file_comment */ ;
if ((err == UNZ_OK) && (pfile_info!=NULL))
@@ -1190,7 +1190,7 @@ extern int ZEXPORT unzOpenCurrentFile3(unzFile file, int* method, int* level, in
(compression_method != Z_BZIP2ED) &&
#endif
(compression_method != Z_DEFLATED))
err = UNZ_BADZIPFILE;
/* err = UNZ_BADZIPFILE */ ;
pfile_in_zip_read_info->crc32_wait = s->cur_file_info.crc;
pfile_in_zip_read_info->crc32 = 0;
@@ -1677,29 +1677,29 @@ extern int ZEXPORT unzCloseCurrentFile(unzFile file)
return err;
}
extern int ZEXPORT unzGoToFirstFile2(unzFile file, unz_file_info64 *pfile_info, char *filename,
uLong filename_size, void *extrafield, uLong extrafield_size, char *comment, uLong comment_size)
{
int err = UNZ_OK;
unz64_s* s;
if (file == NULL)
return UNZ_PARAMERROR;
s = (unz64_s*)file;
s->pos_in_central_dir = s->offset_central_dir;
s->num_file = 0;
uLong filename_size, void *extrafield, uLong extrafield_size, char *comment, uLong comment_size)
{
int err = UNZ_OK;
unz64_s* s;
if (file == NULL)
return UNZ_PARAMERROR;
s = (unz64_s*)file;
s->pos_in_central_dir = s->offset_central_dir;
s->num_file = 0;
err = unz64local_GetCurrentFileInfoInternal(file, &s->cur_file_info, &s->cur_file_info_internal,
filename,filename_size, extrafield,extrafield_size, comment,comment_size);
s->current_file_ok = (err == UNZ_OK);
if ((err == UNZ_OK) && (pfile_info != NULL))
memcpy(pfile_info, &s->cur_file_info, sizeof(unz_file_info64));
return err;
}
extern int ZEXPORT unzGoToFirstFile(unzFile file)
{
return unzGoToFirstFile2(file, NULL, NULL, 0, NULL, 0, NULL, 0);
}
memcpy(pfile_info, &s->cur_file_info, sizeof(unz_file_info64));
return err;
}
extern int ZEXPORT unzGoToFirstFile(unzFile file)
{
return unzGoToFirstFile2(file, NULL, NULL, 0, NULL, 0, NULL, 0);
}
extern int ZEXPORT unzGoToNextFile2(unzFile file, unz_file_info64 *pfile_info, char *filename,
uLong filename_size, void *extrafield, uLong extrafield_size, char *comment, uLong comment_size)
+7 -6
View File
@@ -830,6 +830,7 @@ extern zipFile ZEXPORT zipOpen4(const void *pathname, int append, ZPOS64_T disk_
if (err != ZIP_OK)
{
TRYFREE(zi);
ZCLOSE64(ziinit.z_filefunc, ziinit.filestream);
return NULL;
}
@@ -1040,7 +1041,7 @@ extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, c
if (zi->disk_size > 0)
{
if ((zi->number_disk == 0) && (zi->number_entry == 0))
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (uLong)DISKHEADERMAGIC, 4);
/* err = */ zip64local_putValue(&zi->z_filefunc, zi->filestream, (uLong)DISKHEADERMAGIC, 4);
/* Make sure enough space available on current disk for local header */
zipGetDiskSizeAvailable((zipFile)zi, &size_available);
@@ -1183,10 +1184,10 @@ extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, c
(needed when we update size after done with file) */
zi->ci.pos_zip64extrainfo = ZTELL64(zi->z_filefunc, zi->filestream);
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (short)headerid, 2);
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (short)datasize, 2);
/* err = */ zip64local_putValue(&zi->z_filefunc, zi->filestream, (short)headerid, 2);
/* err = */ zip64local_putValue(&zi->z_filefunc, zi->filestream, (short)datasize, 2);
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)uncompressed_size, 8);
/* err = */ zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)uncompressed_size, 8);
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)compressed_size, 8);
}
#ifdef HAVE_AES
@@ -1586,7 +1587,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si
if (zi->ci.stream.avail_out == 0)
{
if (zip64FlushWriteBuffer(zi) == ZIP_ERRNO)
err = ZIP_ERRNO;
/* err = ZIP_ERRNO */ ;
zi->ci.stream.avail_out = (uInt)Z_BUFSIZE;
zi->ci.stream.next_out = zi->ci.buffered_data;
}
@@ -1725,7 +1726,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si
if(zi->ci.pos_local_header >= 0xffffffff)
{
zip64local_putValue_inmemory(p, zi->ci.pos_local_header, 8);
p += 8;
/* p += 8 */ ;
}
zi->ci.size_centralExtraFree -= datasize + 4;