mirror of
				https://github.com/eledio-devices/thirdparty-miniz.git
				synced 2025-10-31 00:32:38 +01:00 
			
		
		
		
	Fix compile issues with "gcc -ansi"
This commit is contained in:
		| @@ -26,7 +26,12 @@ | ||||
|   | ||||
| #include "miniz_tinfl.h" | ||||
|  | ||||
| // ------------------- Low-level Decompression (completely independent from all compression API's) | ||||
| #ifdef __cplusplus | ||||
| extern "C" { | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* ------------------- Low-level Decompression (completely independent from all compression API's) */ | ||||
|  | ||||
| #define TINFL_MEMCPY(d, s, l) memcpy(d, s, l) | ||||
| #define TINFL_MEMSET(p, c, l) memset(p, c, l) | ||||
| @@ -98,10 +103,10 @@ | ||||
|     }                                        \ | ||||
|     MZ_MACRO_END | ||||
|  | ||||
| // TINFL_HUFF_BITBUF_FILL() is only used rarely, when the number of bytes remaining in the input buffer falls below 2. | ||||
| // It reads just enough bytes from the input stream that are needed to decode the next Huffman code (and absolutely no more). It works by trying to fully decode a | ||||
| // Huffman code by using whatever bits are currently present in the bit buffer. If this fails, it reads another byte, and tries again until it succeeds or until the | ||||
| // bit buffer contains >=15 bits (deflate's max. Huffman code size). | ||||
| /* TINFL_HUFF_BITBUF_FILL() is only used rarely, when the number of bytes remaining in the input buffer falls below 2. */ | ||||
| /* It reads just enough bytes from the input stream that are needed to decode the next Huffman code (and absolutely no more). It works by trying to fully decode a */ | ||||
| /* Huffman code by using whatever bits are currently present in the bit buffer. If this fails, it reads another byte, and tries again until it succeeds or until the */ | ||||
| /* bit buffer contains >=15 bits (deflate's max. Huffman code size). */ | ||||
| #define TINFL_HUFF_BITBUF_FILL(state_index, pHuff)                             \ | ||||
|     do                                                                         \ | ||||
|     {                                                                          \ | ||||
| @@ -127,12 +132,12 @@ | ||||
|         num_bits += 8;                                                         \ | ||||
|     } while (num_bits < 15); | ||||
|  | ||||
| // TINFL_HUFF_DECODE() decodes the next Huffman coded symbol. It's more complex than you would initially expect because the zlib API expects the decompressor to never read | ||||
| // beyond the final byte of the deflate stream. (In other words, when this macro wants to read another byte from the input, it REALLY needs another byte in order to fully | ||||
| // decode the next Huffman code.) Handling this properly is particularly important on raw deflate (non-zlib) streams, which aren't followed by a byte aligned adler-32. | ||||
| // The slow path is only executed at the very end of the input buffer. | ||||
| // v1.16: The original macro handled the case at the very end of the passed-in input buffer, but we also need to handle the case where the user passes in 1+zillion bytes | ||||
| // following the deflate data and our non-conservative read-ahead path won't kick in here on this code. This is much trickier. | ||||
| /* TINFL_HUFF_DECODE() decodes the next Huffman coded symbol. It's more complex than you would initially expect because the zlib API expects the decompressor to never read */ | ||||
| /* beyond the final byte of the deflate stream. (In other words, when this macro wants to read another byte from the input, it REALLY needs another byte in order to fully */ | ||||
| /* decode the next Huffman code.) Handling this properly is particularly important on raw deflate (non-zlib) streams, which aren't followed by a byte aligned adler-32. */ | ||||
| /* The slow path is only executed at the very end of the input buffer. */ | ||||
| /* v1.16: The original macro handled the case at the very end of the passed-in input buffer, but we also need to handle the case where the user passes in 1+zillion bytes */ | ||||
| /* following the deflate data and our non-conservative read-ahead path won't kick in here on this code. This is much trickier. */ | ||||
| #define TINFL_HUFF_DECODE(state_index, sym, pHuff)                                                                                  \ | ||||
|     do                                                                                                                              \ | ||||
|     {                                                                                                                               \ | ||||
| @@ -183,7 +188,7 @@ tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_nex | ||||
|     mz_uint8 *pOut_buf_cur = pOut_buf_next, *const pOut_buf_end = pOut_buf_next + *pOut_buf_size; | ||||
|     size_t out_buf_size_mask = (decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF) ? (size_t) - 1 : ((pOut_buf_next - pOut_buf_start) + *pOut_buf_size) - 1, dist_from_out_buf_start; | ||||
|  | ||||
|     // Ensure the output buffer's size is a power of 2, unless the output buffer is large enough to hold the entire output file (in which case it doesn't matter). | ||||
|     /* Ensure the output buffer's size is a power of 2, unless the output buffer is large enough to hold the entire output file (in which case it doesn't matter). */ | ||||
|     if (((out_buf_size_mask + 1) & out_buf_size_mask) || (pOut_buf_next < pOut_buf_start)) | ||||
|     { | ||||
|         *pIn_buf_size = *pOut_buf_size = 0; | ||||
| @@ -555,8 +560,8 @@ tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_nex | ||||
|         } | ||||
|     } while (!(r->m_final & 1)); | ||||
|  | ||||
|     // Ensure byte alignment and put back any bytes from the bitbuf if we've looked ahead too far on gzip, or other Deflate streams followed by arbitrary data. | ||||
|     // I'm being super conservative here. A number of simplifications can be made to the byte alignment part, and the Adler32 check shouldn't ever need to worry about reading from the bitbuf now. | ||||
|     /* Ensure byte alignment and put back any bytes from the bitbuf if we've looked ahead too far on gzip, or other Deflate streams followed by arbitrary data. */ | ||||
|     /* I'm being super conservative here. A number of simplifications can be made to the byte alignment part, and the Adler32 check shouldn't ever need to worry about reading from the bitbuf now. */ | ||||
|     TINFL_SKIP_BITS(32, num_bits & 7); | ||||
|     while ((pIn_buf_cur > pIn_buf_next) && (num_bits >= 8)) | ||||
|     { | ||||
| @@ -564,7 +569,7 @@ tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_nex | ||||
|         num_bits -= 8; | ||||
|     } | ||||
|     bit_buf &= (tinfl_bit_buf_t)((1ULL << num_bits) - 1ULL); | ||||
|     MZ_ASSERT(!num_bits); // if this assert fires then we've read beyond the end of non-deflate/zlib streams with following data (such as gzip streams). | ||||
|     MZ_ASSERT(!num_bits); /* if this assert fires then we've read beyond the end of non-deflate/zlib streams with following data (such as gzip streams). */ | ||||
|  | ||||
|     if (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER) | ||||
|     { | ||||
| @@ -583,9 +588,9 @@ tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_nex | ||||
|     TINFL_CR_FINISH | ||||
|  | ||||
| common_exit: | ||||
|     // As long as we aren't telling the caller that we NEED more input to make forward progress: | ||||
|     // Put back any bytes from the bitbuf in case we've looked ahead too far on gzip, or other Deflate streams followed by arbitrary data. | ||||
|     // We need to be very careful here to NOT push back any bytes we definitely know we need to make forward progress, though, or we'll lock the caller up into an inf loop. | ||||
|     /* As long as we aren't telling the caller that we NEED more input to make forward progress: */ | ||||
|     /* Put back any bytes from the bitbuf in case we've looked ahead too far on gzip, or other Deflate streams followed by arbitrary data. */ | ||||
|     /* We need to be very careful here to NOT push back any bytes we definitely know we need to make forward progress, though, or we'll lock the caller up into an inf loop. */ | ||||
|     if ((status != TINFL_STATUS_NEEDS_MORE_INPUT) && (status != TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS)) | ||||
|     { | ||||
|         while ((pIn_buf_cur > pIn_buf_next) && (num_bits >= 8)) | ||||
| @@ -634,7 +639,7 @@ common_exit: | ||||
|     return status; | ||||
| } | ||||
|  | ||||
| // Higher level helper functions. | ||||
| /* Higher level helper functions. */ | ||||
| void *tinfl_decompress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags) | ||||
| { | ||||
|     tinfl_decompressor decomp; | ||||
| @@ -723,3 +728,8 @@ void tinfl_decompressor_free(tinfl_decompressor *pDecomp) | ||||
| { | ||||
|     MZ_FREE(pDecomp); | ||||
| } | ||||
|  | ||||
| #ifdef __cplusplus | ||||
| } | ||||
| #endif | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user