mirror of
https://github.com/eledio-devices/thirdparty-miniz.git
synced 2025-10-30 16:15:41 +01:00
Merge remote-tracking branch 'ccawley2011/mingw-watcom'
# Conflicts: # examples/example6.c
This commit is contained in:
@@ -100,7 +100,7 @@ int main(int argc, char *argv[])
|
||||
file_loc = ftell(pInfile);
|
||||
fseek(pInfile, 0, SEEK_SET);
|
||||
|
||||
if ((file_loc < 0) || (file_loc > INT_MAX))
|
||||
if ((file_loc < 0) || ((mz_uint64)file_loc > INT_MAX))
|
||||
{
|
||||
// This is not a limitation of miniz or tinfl, but this example.
|
||||
printf("File is too large to be processed by this example.\n");
|
||||
|
||||
@@ -47,7 +47,7 @@ int main(int argc, char *argv[])
|
||||
file_loc = ftell(pInfile);
|
||||
fseek(pInfile, 0, SEEK_SET);
|
||||
|
||||
if ((file_loc < 0) || (file_loc > INT_MAX))
|
||||
if ((file_loc < 0) || ((mz_uint64)file_loc > INT_MAX))
|
||||
{
|
||||
// This is not a limitation of miniz or tinfl, but this example.
|
||||
printf("File is too large to be processed by this example.\n");
|
||||
|
||||
@@ -132,7 +132,7 @@ int main(int argc, char *argv[])
|
||||
file_loc = ftell(pInfile);
|
||||
fseek(pInfile, 0, SEEK_SET);
|
||||
|
||||
if ((file_loc < 0) || (file_loc > INT_MAX))
|
||||
if ((file_loc < 0) || ((mz_uint64)file_loc > INT_MAX))
|
||||
{
|
||||
// This is not a limitation of miniz or tinfl, but this example.
|
||||
printf("File is too large to be processed by this example.\n");
|
||||
|
||||
@@ -91,6 +91,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
int MinIter = 9999, MaxIter = 0;
|
||||
|
||||
(void)argc, (void)argv;
|
||||
|
||||
for(iY = 0; iY < iYmax; iY++)
|
||||
{
|
||||
Cy = CyMin + iY * PixelHeight;
|
||||
|
||||
4
miniz.c
4
miniz.c
@@ -320,7 +320,7 @@ int mz_compress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char
|
||||
memset(&stream, 0, sizeof(stream));
|
||||
|
||||
/* In case mz_ulong is 64-bits (argh I hate longs). */
|
||||
if ((source_len | *pDest_len) > 0xFFFFFFFFU)
|
||||
if ((mz_uint64)(source_len | *pDest_len) > 0xFFFFFFFFU)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
stream.next_in = pSource;
|
||||
@@ -559,7 +559,7 @@ int mz_uncompress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned cha
|
||||
memset(&stream, 0, sizeof(stream));
|
||||
|
||||
/* In case mz_ulong is 64-bits (argh I hate longs). */
|
||||
if ((*pSource_len | *pDest_len) > 0xFFFFFFFFU)
|
||||
if ((mz_uint64)(*pSource_len | *pDest_len) > 0xFFFFFFFFU)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
stream.next_in = pSource;
|
||||
|
||||
@@ -58,6 +58,8 @@ typedef struct mz_dummy_time_t_tag
|
||||
#define MZ_MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#define MZ_MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#define MZ_CLEAR_OBJ(obj) memset(&(obj), 0, sizeof(obj))
|
||||
#define MZ_CLEAR_ARR(obj) memset((obj), 0, sizeof(obj))
|
||||
#define MZ_CLEAR_PTR(obj) memset((obj), 0, sizeof(*obj))
|
||||
|
||||
#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN
|
||||
#define MZ_READ_LE16(p) *((const mz_uint16 *)(p))
|
||||
|
||||
16
miniz_tdef.c
16
miniz_tdef.c
@@ -104,7 +104,7 @@ static tdefl_sym_freq *tdefl_radix_sort_syms(mz_uint num_syms, tdefl_sym_freq *p
|
||||
{
|
||||
mz_uint32 total_passes = 2, pass_shift, pass, i, hist[256 * 2];
|
||||
tdefl_sym_freq *pCur_syms = pSyms0, *pNew_syms = pSyms1;
|
||||
MZ_CLEAR_OBJ(hist);
|
||||
MZ_CLEAR_ARR(hist);
|
||||
for (i = 0; i < num_syms; i++)
|
||||
{
|
||||
mz_uint freq = pSyms0[i].m_key;
|
||||
@@ -222,7 +222,7 @@ static void tdefl_optimize_huffman_table(tdefl_compressor *d, int table_num, int
|
||||
{
|
||||
int i, j, l, num_codes[1 + TDEFL_MAX_SUPPORTED_HUFF_CODESIZE];
|
||||
mz_uint next_code[TDEFL_MAX_SUPPORTED_HUFF_CODESIZE + 1];
|
||||
MZ_CLEAR_OBJ(num_codes);
|
||||
MZ_CLEAR_ARR(num_codes);
|
||||
if (static_table)
|
||||
{
|
||||
for (i = 0; i < table_len; i++)
|
||||
@@ -248,8 +248,8 @@ static void tdefl_optimize_huffman_table(tdefl_compressor *d, int table_num, int
|
||||
|
||||
tdefl_huffman_enforce_max_code_size(num_codes, num_used_syms, code_size_limit);
|
||||
|
||||
MZ_CLEAR_OBJ(d->m_huff_code_sizes[table_num]);
|
||||
MZ_CLEAR_OBJ(d->m_huff_codes[table_num]);
|
||||
MZ_CLEAR_ARR(d->m_huff_code_sizes[table_num]);
|
||||
MZ_CLEAR_ARR(d->m_huff_codes[table_num]);
|
||||
for (i = 1, j = num_used_syms; i <= code_size_limit; i++)
|
||||
for (l = num_codes[i]; l > 0; l--)
|
||||
d->m_huff_code_sizes[table_num][pSyms[--j].m_sym_index] = (mz_uint8)(i);
|
||||
@@ -1302,8 +1302,8 @@ tdefl_status tdefl_compress(tdefl_compressor *d, const void *pIn_buf, size_t *pI
|
||||
d->m_finished = (flush == TDEFL_FINISH);
|
||||
if (flush == TDEFL_FULL_FLUSH)
|
||||
{
|
||||
MZ_CLEAR_OBJ(d->m_hash);
|
||||
MZ_CLEAR_OBJ(d->m_next);
|
||||
MZ_CLEAR_ARR(d->m_hash);
|
||||
MZ_CLEAR_ARR(d->m_next);
|
||||
d->m_dict_size = 0;
|
||||
}
|
||||
}
|
||||
@@ -1326,7 +1326,7 @@ tdefl_status tdefl_init(tdefl_compressor *d, tdefl_put_buf_func_ptr pPut_buf_fun
|
||||
d->m_greedy_parsing = (flags & TDEFL_GREEDY_PARSING_FLAG) != 0;
|
||||
d->m_max_probes[1] = 1 + (((flags & 0xFFF) >> 2) + 2) / 3;
|
||||
if (!(flags & TDEFL_NONDETERMINISTIC_PARSING_FLAG))
|
||||
MZ_CLEAR_OBJ(d->m_hash);
|
||||
MZ_CLEAR_ARR(d->m_hash);
|
||||
d->m_lookahead_pos = d->m_lookahead_size = d->m_dict_size = d->m_total_lz_bytes = d->m_lz_code_buf_dict_pos = d->m_bits_in = 0;
|
||||
d->m_output_flush_ofs = d->m_output_flush_remaining = d->m_finished = d->m_block_index = d->m_bit_buffer = d->m_wants_to_finish = 0;
|
||||
d->m_pLZ_code_buf = d->m_lz_code_buf + 1;
|
||||
@@ -1347,7 +1347,7 @@ tdefl_status tdefl_init(tdefl_compressor *d, tdefl_put_buf_func_ptr pPut_buf_fun
|
||||
d->m_src_buf_left = 0;
|
||||
d->m_out_buf_ofs = 0;
|
||||
if (!(flags & TDEFL_NONDETERMINISTIC_PARSING_FLAG))
|
||||
MZ_CLEAR_OBJ(d->m_dict);
|
||||
MZ_CLEAR_ARR(d->m_dict);
|
||||
memset(&d->m_huff_count[0][0], 0, sizeof(d->m_huff_count[0][0]) * TDEFL_MAX_HUFF_SYMBOLS_0);
|
||||
memset(&d->m_huff_count[1][0], 0, sizeof(d->m_huff_count[1][0]) * TDEFL_MAX_HUFF_SYMBOLS_1);
|
||||
return TDEFL_STATUS_OKAY;
|
||||
|
||||
@@ -292,7 +292,7 @@ tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_nex
|
||||
TINFL_GET_BITS(11, r->m_table_sizes[counter], "\05\05\04"[counter]);
|
||||
r->m_table_sizes[counter] += s_min_table_sizes[counter];
|
||||
}
|
||||
MZ_CLEAR_OBJ(r->m_tables[2].m_code_size);
|
||||
MZ_CLEAR_ARR(r->m_tables[2].m_code_size);
|
||||
for (counter = 0; counter < r->m_table_sizes[2]; counter++)
|
||||
{
|
||||
mz_uint s;
|
||||
@@ -307,9 +307,9 @@ tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_nex
|
||||
tinfl_huff_table *pTable;
|
||||
mz_uint i, j, used_syms, total, sym_index, next_code[17], total_syms[16];
|
||||
pTable = &r->m_tables[r->m_type];
|
||||
MZ_CLEAR_OBJ(total_syms);
|
||||
MZ_CLEAR_OBJ(pTable->m_look_up);
|
||||
MZ_CLEAR_OBJ(pTable->m_tree);
|
||||
MZ_CLEAR_ARR(total_syms);
|
||||
MZ_CLEAR_ARR(pTable->m_look_up);
|
||||
MZ_CLEAR_ARR(pTable->m_tree);
|
||||
for (i = 0; i < r->m_table_sizes[r->m_type]; ++i)
|
||||
total_syms[pTable->m_code_size[i]]++;
|
||||
used_syms = 0, total = 0;
|
||||
|
||||
28
miniz_zip.c
28
miniz_zip.c
@@ -96,7 +96,7 @@ static int mz_stat64(const char *path, struct __stat64 *buffer)
|
||||
#define MZ_FFLUSH fflush
|
||||
#define MZ_FREOPEN mz_freopen
|
||||
#define MZ_DELETE_FILE remove
|
||||
#elif defined(__MINGW32__)
|
||||
#elif defined(__MINGW32__) || defined(__WATCOMC__)
|
||||
#ifndef MINIZ_NO_TIME
|
||||
#include <sys/utime.h>
|
||||
#endif
|
||||
@@ -104,10 +104,10 @@ static int mz_stat64(const char *path, struct __stat64 *buffer)
|
||||
#define MZ_FCLOSE fclose
|
||||
#define MZ_FREAD fread
|
||||
#define MZ_FWRITE fwrite
|
||||
#define MZ_FTELL64 ftello64
|
||||
#define MZ_FSEEK64 fseeko64
|
||||
#define MZ_FILE_STAT_STRUCT _stat
|
||||
#define MZ_FILE_STAT _stat
|
||||
#define MZ_FTELL64 _ftelli64
|
||||
#define MZ_FSEEK64 _fseeki64
|
||||
#define MZ_FILE_STAT_STRUCT stat
|
||||
#define MZ_FILE_STAT stat
|
||||
#define MZ_FFLUSH fflush
|
||||
#define MZ_FREOPEN(f, m, s) freopen(f, m, s)
|
||||
#define MZ_DELETE_FILE remove
|
||||
@@ -874,7 +874,7 @@ static mz_bool mz_zip_reader_read_central_dir(mz_zip_archive *pZip, mz_uint flag
|
||||
void mz_zip_zero_struct(mz_zip_archive *pZip)
|
||||
{
|
||||
if (pZip)
|
||||
MZ_CLEAR_OBJ(*pZip);
|
||||
MZ_CLEAR_PTR(pZip);
|
||||
}
|
||||
|
||||
static mz_bool mz_zip_reader_end_internal(mz_zip_archive *pZip, mz_bool set_last_error)
|
||||
@@ -2860,7 +2860,7 @@ mz_bool mz_zip_writer_init_file_v2(mz_zip_archive *pZip, const char *pFilename,
|
||||
mz_uint64 cur_ofs = 0;
|
||||
char buf[4096];
|
||||
|
||||
MZ_CLEAR_OBJ(buf);
|
||||
MZ_CLEAR_ARR(buf);
|
||||
|
||||
do
|
||||
{
|
||||
@@ -3223,7 +3223,7 @@ mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive *pZip, const char *pArchive_n
|
||||
pState->m_zip64 = MZ_TRUE;
|
||||
/*return mz_zip_set_error(pZip, MZ_ZIP_TOO_MANY_FILES); */
|
||||
}
|
||||
if ((buf_size > 0xFFFFFFFF) || (uncomp_size > 0xFFFFFFFF))
|
||||
if (((mz_uint64)buf_size > 0xFFFFFFFF) || (uncomp_size > 0xFFFFFFFF))
|
||||
{
|
||||
pState->m_zip64 = MZ_TRUE;
|
||||
/*return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE); */
|
||||
@@ -3316,7 +3316,7 @@ mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive *pZip, const char *pArchive_n
|
||||
}
|
||||
cur_archive_file_ofs += num_alignment_padding_bytes;
|
||||
|
||||
MZ_CLEAR_OBJ(local_dir_header);
|
||||
MZ_CLEAR_ARR(local_dir_header);
|
||||
|
||||
if (!store_data_uncompressed || (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA))
|
||||
{
|
||||
@@ -3569,7 +3569,7 @@ mz_bool mz_zip_writer_add_read_buf_callback(mz_zip_archive *pZip, const char *pA
|
||||
method = MZ_DEFLATED;
|
||||
}
|
||||
|
||||
MZ_CLEAR_OBJ(local_dir_header);
|
||||
MZ_CLEAR_ARR(local_dir_header);
|
||||
if (pState->m_zip64)
|
||||
{
|
||||
if (max_size >= MZ_UINT32_MAX || local_dir_header_ofs >= MZ_UINT32_MAX)
|
||||
@@ -4328,7 +4328,7 @@ mz_bool mz_zip_writer_finalize_archive(mz_zip_archive *pZip)
|
||||
|
||||
if (pState->m_zip64)
|
||||
{
|
||||
if ((pZip->m_total_files > MZ_UINT32_MAX) || (pState->m_central_dir.m_size >= MZ_UINT32_MAX))
|
||||
if (((mz_uint64)pZip->m_total_files > MZ_UINT32_MAX) || (pState->m_central_dir.m_size >= MZ_UINT32_MAX))
|
||||
return mz_zip_set_error(pZip, MZ_ZIP_TOO_MANY_FILES);
|
||||
}
|
||||
else
|
||||
@@ -4356,7 +4356,7 @@ mz_bool mz_zip_writer_finalize_archive(mz_zip_archive *pZip)
|
||||
/* Write zip64 end of central directory header */
|
||||
mz_uint64 rel_ofs_to_zip64_ecdr = pZip->m_archive_size;
|
||||
|
||||
MZ_CLEAR_OBJ(hdr);
|
||||
MZ_CLEAR_ARR(hdr);
|
||||
MZ_WRITE_LE32(hdr + MZ_ZIP64_ECDH_SIG_OFS, MZ_ZIP64_END_OF_CENTRAL_DIR_HEADER_SIG);
|
||||
MZ_WRITE_LE64(hdr + MZ_ZIP64_ECDH_SIZE_OF_RECORD_OFS, MZ_ZIP64_END_OF_CENTRAL_DIR_HEADER_SIZE - sizeof(mz_uint32) - sizeof(mz_uint64));
|
||||
MZ_WRITE_LE16(hdr + MZ_ZIP64_ECDH_VERSION_MADE_BY_OFS, 0x031E); /* TODO: always Unix */
|
||||
@@ -4371,7 +4371,7 @@ mz_bool mz_zip_writer_finalize_archive(mz_zip_archive *pZip)
|
||||
pZip->m_archive_size += MZ_ZIP64_END_OF_CENTRAL_DIR_HEADER_SIZE;
|
||||
|
||||
/* Write zip64 end of central directory locator */
|
||||
MZ_CLEAR_OBJ(hdr);
|
||||
MZ_CLEAR_ARR(hdr);
|
||||
MZ_WRITE_LE32(hdr + MZ_ZIP64_ECDL_SIG_OFS, MZ_ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIG);
|
||||
MZ_WRITE_LE64(hdr + MZ_ZIP64_ECDL_REL_OFS_TO_ZIP64_ECDR_OFS, rel_ofs_to_zip64_ecdr);
|
||||
MZ_WRITE_LE32(hdr + MZ_ZIP64_ECDL_TOTAL_NUMBER_OF_DISKS_OFS, 1);
|
||||
@@ -4382,7 +4382,7 @@ mz_bool mz_zip_writer_finalize_archive(mz_zip_archive *pZip)
|
||||
}
|
||||
|
||||
/* Write end of central directory record */
|
||||
MZ_CLEAR_OBJ(hdr);
|
||||
MZ_CLEAR_ARR(hdr);
|
||||
MZ_WRITE_LE32(hdr + MZ_ZIP_ECDH_SIG_OFS, MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG);
|
||||
MZ_WRITE_LE16(hdr + MZ_ZIP_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS, MZ_MIN(MZ_UINT16_MAX, pZip->m_total_files));
|
||||
MZ_WRITE_LE16(hdr + MZ_ZIP_ECDH_CDIR_TOTAL_ENTRIES_OFS, MZ_MIN(MZ_UINT16_MAX, pZip->m_total_files));
|
||||
|
||||
Reference in New Issue
Block a user