mirror of
				https://github.com/eledio-devices/thirdparty-miniz.git
				synced 2025-10-31 08:42:39 +01:00 
			
		
		
		
	clang-format the sources
This commit is contained in:
		
							
								
								
									
										7
									
								
								miniz.c
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								miniz.c
									
									
									
									
									
								
							| @@ -320,7 +320,7 @@ int mz_compress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char | |||||||
|     stream.next_in = pSource; |     stream.next_in = pSource; | ||||||
|     stream.avail_in = (mz_uint32)source_len; |     stream.avail_in = (mz_uint32)source_len; | ||||||
|     stream.next_out = pDest; |     stream.next_out = pDest; | ||||||
|     stream.avail_out = (mz_uint32) * pDest_len; |     stream.avail_out = (mz_uint32)*pDest_len; | ||||||
|  |  | ||||||
|     status = mz_deflateInit(&stream, level); |     status = mz_deflateInit(&stream, level); | ||||||
|     if (status != MZ_OK) |     if (status != MZ_OK) | ||||||
| @@ -534,7 +534,7 @@ int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char | |||||||
|     stream.next_in = pSource; |     stream.next_in = pSource; | ||||||
|     stream.avail_in = (mz_uint32)source_len; |     stream.avail_in = (mz_uint32)source_len; | ||||||
|     stream.next_out = pDest; |     stream.next_out = pDest; | ||||||
|     stream.avail_out = (mz_uint32) * pDest_len; |     stream.avail_out = (mz_uint32)*pDest_len; | ||||||
|  |  | ||||||
|     status = mz_inflateInit(&stream); |     status = mz_inflateInit(&stream); | ||||||
|     if (status != MZ_OK) |     if (status != MZ_OK) | ||||||
| @@ -559,8 +559,7 @@ const char *mz_error(int err) | |||||||
|         const char *m_pDesc; |         const char *m_pDesc; | ||||||
|     } s_error_descs[] = |     } s_error_descs[] = | ||||||
|         { |         { | ||||||
|               { MZ_OK, "" }, { MZ_STREAM_END, "stream end" }, { MZ_NEED_DICT, "need dictionary" }, { MZ_ERRNO, "file error" }, { MZ_STREAM_ERROR, "stream error" }, |           { MZ_OK, "" }, { MZ_STREAM_END, "stream end" }, { MZ_NEED_DICT, "need dictionary" }, { MZ_ERRNO, "file error" }, { MZ_STREAM_ERROR, "stream error" }, { MZ_DATA_ERROR, "data error" }, { MZ_MEM_ERROR, "out of memory" }, { MZ_BUF_ERROR, "buf error" }, { MZ_VERSION_ERROR, "version error" }, { MZ_PARAM_ERROR, "parameter error" } | ||||||
|               { MZ_DATA_ERROR, "data error" }, { MZ_MEM_ERROR, "out of memory" }, { MZ_BUF_ERROR, "buf error" }, { MZ_VERSION_ERROR, "version error" }, { MZ_PARAM_ERROR, "parameter error" } |  | ||||||
|         }; |         }; | ||||||
|     mz_uint i; |     mz_uint i; | ||||||
|     for (i = 0; i < sizeof(s_error_descs) / sizeof(s_error_descs[0]); ++i) |     for (i = 0; i < sizeof(s_error_descs) / sizeof(s_error_descs[0]); ++i) | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								miniz.h
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								miniz.h
									
									
									
									
									
								
							| @@ -212,7 +212,7 @@ enum | |||||||
| /* Heap allocation callbacks. | /* Heap allocation callbacks. | ||||||
| Note that mz_alloc_func parameter types purpsosely differ from zlib's: items/size is size_t, not unsigned long. */ | Note that mz_alloc_func parameter types purpsosely differ from zlib's: items/size is size_t, not unsigned long. */ | ||||||
| typedef void *(*mz_alloc_func)(void *opaque, size_t items, size_t size); | typedef void *(*mz_alloc_func)(void *opaque, size_t items, size_t size); | ||||||
| typedef void(*mz_free_func)(void *opaque, void *address); | typedef void (*mz_free_func)(void *opaque, void *address); | ||||||
| typedef void *(*mz_realloc_func)(void *opaque, void *address, size_t items, size_t size); | typedef void *(*mz_realloc_func)(void *opaque, void *address, size_t items, size_t size); | ||||||
|  |  | ||||||
| /* Compression levels: 0-9 are the standard zlib-style levels, 10 is best possible compression (not zlib compatible, and may be very slow), MZ_DEFAULT_COMPRESSION=MZ_DEFAULT_LEVEL. */ | /* Compression levels: 0-9 are the standard zlib-style levels, 10 is best possible compression (not zlib compatible, and may be very slow), MZ_DEFAULT_COMPRESSION=MZ_DEFAULT_LEVEL. */ | ||||||
|   | |||||||
| @@ -1,8 +1,8 @@ | |||||||
| #pragma once | #pragma once | ||||||
| #include <assert.h> | #include <assert.h> | ||||||
|  | #include <stdint.h> | ||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
| #include <stdint.h> |  | ||||||
|  |  | ||||||
| /* ------------------- Types and macros */ | /* ------------------- Types and macros */ | ||||||
| typedef unsigned char mz_uint8; | typedef unsigned char mz_uint8; | ||||||
| @@ -45,7 +45,7 @@ typedef struct mz_dummy_time_t_tag | |||||||
|  |  | ||||||
| #ifdef MINIZ_NO_MALLOC | #ifdef MINIZ_NO_MALLOC | ||||||
| #define MZ_MALLOC(x) NULL | #define MZ_MALLOC(x) NULL | ||||||
| #define MZ_FREE(x) (void) x, ((void)0) | #define MZ_FREE(x) (void)x, ((void)0) | ||||||
| #define MZ_REALLOC(p, x) NULL | #define MZ_REALLOC(p, x) NULL | ||||||
| #else | #else | ||||||
| #define MZ_MALLOC(x) malloc(x) | #define MZ_MALLOC(x) malloc(x) | ||||||
| @@ -57,7 +57,7 @@ typedef struct mz_dummy_time_t_tag | |||||||
| #define MZ_MIN(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_OBJ(obj) memset(&(obj), 0, sizeof(obj)) | ||||||
|  |  | ||||||
| #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES &&MINIZ_LITTLE_ENDIAN | #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN | ||||||
| #define MZ_READ_LE16(p) *((const mz_uint16 *)(p)) | #define MZ_READ_LE16(p) *((const mz_uint16 *)(p)) | ||||||
| #define MZ_READ_LE32(p) *((const mz_uint32 *)(p)) | #define MZ_READ_LE32(p) *((const mz_uint32 *)(p)) | ||||||
| #else | #else | ||||||
|   | |||||||
| @@ -449,7 +449,7 @@ static void tdefl_start_static_block(tdefl_compressor *d) | |||||||
|  |  | ||||||
| static const mz_uint mz_bitmasks[17] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F, 0x00FF, 0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF }; | static const mz_uint mz_bitmasks[17] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F, 0x00FF, 0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF }; | ||||||
|  |  | ||||||
| #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES &&MINIZ_LITTLE_ENDIAN &&MINIZ_HAS_64BIT_REGISTERS | #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN && MINIZ_HAS_64BIT_REGISTERS | ||||||
| static mz_bool tdefl_compress_lz_codes(tdefl_compressor *d) | static mz_bool tdefl_compress_lz_codes(tdefl_compressor *d) | ||||||
| { | { | ||||||
|     mz_uint flags; |     mz_uint flags; | ||||||
| @@ -836,7 +836,7 @@ static MZ_FORCEINLINE void tdefl_find_match(tdefl_compressor *d, mz_uint lookahe | |||||||
| } | } | ||||||
| #endif /* #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES */ | #endif /* #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES */ | ||||||
|  |  | ||||||
| #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES &&MINIZ_LITTLE_ENDIAN | #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN | ||||||
| static mz_bool tdefl_compress_fast(tdefl_compressor *d) | static mz_bool tdefl_compress_fast(tdefl_compressor *d) | ||||||
| { | { | ||||||
|     /* Faster, minimally featured LZRW1-style match+parse loop with better register utilization. Intended for applications where raw throughput is valued more highly than ratio. */ |     /* Faster, minimally featured LZRW1-style match+parse loop with better register utilization. Intended for applications where raw throughput is valued more highly than ratio. */ | ||||||
| @@ -1250,7 +1250,7 @@ tdefl_status tdefl_compress(tdefl_compressor *d, const void *pIn_buf, size_t *pI | |||||||
|     if ((d->m_output_flush_remaining) || (d->m_finished)) |     if ((d->m_output_flush_remaining) || (d->m_finished)) | ||||||
|         return (d->m_prev_return_status = tdefl_flush_output_buffer(d)); |         return (d->m_prev_return_status = tdefl_flush_output_buffer(d)); | ||||||
|  |  | ||||||
| #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES &&MINIZ_LITTLE_ENDIAN | #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN | ||||||
|     if (((d->m_flags & TDEFL_MAX_PROBES_MASK) == 1) && |     if (((d->m_flags & TDEFL_MAX_PROBES_MASK) == 1) && | ||||||
|         ((d->m_flags & TDEFL_GREEDY_PARSING_FLAG) != 0) && |         ((d->m_flags & TDEFL_GREEDY_PARSING_FLAG) != 0) && | ||||||
|         ((d->m_flags & (TDEFL_FILTER_MATCHES | TDEFL_FORCE_ALL_RAW_BLOCKS | TDEFL_RLE_MATCHES)) == 0)) |         ((d->m_flags & (TDEFL_FILTER_MATCHES | TDEFL_FORCE_ALL_RAW_BLOCKS | TDEFL_RLE_MATCHES)) == 0)) | ||||||
|   | |||||||
| @@ -111,8 +111,7 @@ enum | |||||||
| #endif | #endif | ||||||
|  |  | ||||||
| /* The low-level tdefl functions below may be used directly if the above helper functions aren't flexible enough. The low-level functions don't make any heap allocations, unlike the above helper functions. */ | /* The low-level tdefl functions below may be used directly if the above helper functions aren't flexible enough. The low-level functions don't make any heap allocations, unlike the above helper functions. */ | ||||||
| typedef enum | typedef enum { | ||||||
| { |  | ||||||
|     TDEFL_STATUS_BAD_PARAM = -2, |     TDEFL_STATUS_BAD_PARAM = -2, | ||||||
|     TDEFL_STATUS_PUT_BUF_FAILED = -1, |     TDEFL_STATUS_PUT_BUF_FAILED = -1, | ||||||
|     TDEFL_STATUS_OKAY = 0, |     TDEFL_STATUS_OKAY = 0, | ||||||
| @@ -120,8 +119,7 @@ typedef enum | |||||||
| } tdefl_status; | } tdefl_status; | ||||||
|  |  | ||||||
| /* Must map to MZ_NO_FLUSH, MZ_SYNC_FLUSH, etc. enums */ | /* Must map to MZ_NO_FLUSH, MZ_SYNC_FLUSH, etc. enums */ | ||||||
| typedef enum | typedef enum { | ||||||
| { |  | ||||||
|     TDEFL_NO_FLUSH = 0, |     TDEFL_NO_FLUSH = 0, | ||||||
|     TDEFL_SYNC_FLUSH = 2, |     TDEFL_SYNC_FLUSH = 2, | ||||||
|     TDEFL_FULL_FLUSH = 3, |     TDEFL_FULL_FLUSH = 3, | ||||||
|   | |||||||
| @@ -45,8 +45,7 @@ extern "C" { | |||||||
|         status = result;                     \ |         status = result;                     \ | ||||||
|         r->m_state = state_index;            \ |         r->m_state = state_index;            \ | ||||||
|         goto common_exit;                    \ |         goto common_exit;                    \ | ||||||
|         case state_index:                    \ |         case state_index:;                   \ | ||||||
|             ;                                \ |  | ||||||
|     }                                        \ |     }                                        \ | ||||||
|     MZ_MACRO_END |     MZ_MACRO_END | ||||||
| #define TINFL_CR_RETURN_FOREVER(state_index, result) \ | #define TINFL_CR_RETURN_FOREVER(state_index, result) \ | ||||||
| @@ -65,7 +64,7 @@ extern "C" { | |||||||
|     {                                                                                                                                                            \ |     {                                                                                                                                                            \ | ||||||
|         while (pIn_buf_cur >= pIn_buf_end)                                                                                                                       \ |         while (pIn_buf_cur >= pIn_buf_end)                                                                                                                       \ | ||||||
|         {                                                                                                                                                        \ |         {                                                                                                                                                        \ | ||||||
|             TINFL_CR_RETURN(state_index, (decomp_flags &TINFL_FLAG_HAS_MORE_INPUT) ? TINFL_STATUS_NEEDS_MORE_INPUT : TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS); \ |             TINFL_CR_RETURN(state_index, (decomp_flags & TINFL_FLAG_HAS_MORE_INPUT) ? TINFL_STATUS_NEEDS_MORE_INPUT : TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS); \ | ||||||
|         }                                                                                                                                                        \ |         }                                                                                                                                                        \ | ||||||
|         c = *pIn_buf_cur++;                                                                                                                                      \ |         c = *pIn_buf_cur++;                                                                                                                                      \ | ||||||
|     }                                                                                                                                                            \ |     }                                                                                                                                                            \ | ||||||
| @@ -186,7 +185,7 @@ tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_nex | |||||||
|     tinfl_bit_buf_t bit_buf; |     tinfl_bit_buf_t bit_buf; | ||||||
|     const mz_uint8 *pIn_buf_cur = pIn_buf_next, *const pIn_buf_end = pIn_buf_next + *pIn_buf_size; |     const mz_uint8 *pIn_buf_cur = pIn_buf_next, *const pIn_buf_end = pIn_buf_next + *pIn_buf_size; | ||||||
|     mz_uint8 *pOut_buf_cur = pOut_buf_next, *const pOut_buf_end = pOut_buf_next + *pOut_buf_size; |     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; |     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)) |     if (((out_buf_size_mask + 1) & out_buf_size_mask) || (pOut_buf_next < pOut_buf_start)) | ||||||
| @@ -568,7 +567,7 @@ tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_nex | |||||||
|         --pIn_buf_cur; |         --pIn_buf_cur; | ||||||
|         num_bits -= 8; |         num_bits -= 8; | ||||||
|     } |     } | ||||||
|     bit_buf &= (tinfl_bit_buf_t)(( ((mz_uint64)1) << num_bits) - (mz_uint64)1); |     bit_buf &= (tinfl_bit_buf_t)((((mz_uint64)1) << num_bits) - (mz_uint64)1); | ||||||
|     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) |     if (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER) | ||||||
| @@ -600,7 +599,7 @@ common_exit: | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     r->m_num_bits = num_bits; |     r->m_num_bits = num_bits; | ||||||
|     r->m_bit_buf = bit_buf & (tinfl_bit_buf_t)(( ((mz_uint64)1) << num_bits) - (mz_uint64)1); |     r->m_bit_buf = bit_buf & (tinfl_bit_buf_t)((((mz_uint64)1) << num_bits) - (mz_uint64)1); | ||||||
|     r->m_dist = dist; |     r->m_dist = dist; | ||||||
|     r->m_counter = counter; |     r->m_counter = counter; | ||||||
|     r->m_num_extra = num_extra; |     r->m_num_extra = num_extra; | ||||||
|   | |||||||
| @@ -52,8 +52,7 @@ void tinfl_decompressor_free(tinfl_decompressor *pDecomp); | |||||||
| #define TINFL_LZ_DICT_SIZE 32768 | #define TINFL_LZ_DICT_SIZE 32768 | ||||||
|  |  | ||||||
| /* Return status. */ | /* Return status. */ | ||||||
| typedef enum | typedef enum { | ||||||
| { |  | ||||||
|     /* This flags indicates the inflator needs 1 or more input bytes to make forward progress, but the caller is indicating that no more are available. The compressed data */ |     /* This flags indicates the inflator needs 1 or more input bytes to make forward progress, but the caller is indicating that no more are available. The compressed data */ | ||||||
|     /* is probably corrupted. If you call the inflator again with more bytes it'll try to continue processing the input but this is a BAD sign (either the data is corrupted or you called it incorrectly). */ |     /* is probably corrupted. If you call the inflator again with more bytes it'll try to continue processing the input but this is a BAD sign (either the data is corrupted or you called it incorrectly). */ | ||||||
|     /* If you call it again with no input you'll just get TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS again. */ |     /* If you call it again with no input you'll just get TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS again. */ | ||||||
|   | |||||||
| @@ -4356,4 +4356,3 @@ mz_bool mz_zip_end(mz_zip_archive *pZip) | |||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #endif /*#ifndef MINIZ_NO_ARCHIVE_APIS*/ | #endif /*#ifndef MINIZ_NO_ARCHIVE_APIS*/ | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										12
									
								
								miniz_zip.h
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								miniz_zip.h
									
									
									
									
									
								
							| @@ -81,16 +81,14 @@ typedef mz_bool (*mz_file_needs_keepalive)(void *pOpaque); | |||||||
| struct mz_zip_internal_state_tag; | struct mz_zip_internal_state_tag; | ||||||
| typedef struct mz_zip_internal_state_tag mz_zip_internal_state; | typedef struct mz_zip_internal_state_tag mz_zip_internal_state; | ||||||
|  |  | ||||||
| typedef enum | typedef enum { | ||||||
| { |  | ||||||
|     MZ_ZIP_MODE_INVALID = 0, |     MZ_ZIP_MODE_INVALID = 0, | ||||||
|     MZ_ZIP_MODE_READING = 1, |     MZ_ZIP_MODE_READING = 1, | ||||||
|     MZ_ZIP_MODE_WRITING = 2, |     MZ_ZIP_MODE_WRITING = 2, | ||||||
|     MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED = 3 |     MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED = 3 | ||||||
| } mz_zip_mode; | } mz_zip_mode; | ||||||
|  |  | ||||||
| typedef enum | typedef enum { | ||||||
| { |  | ||||||
|     MZ_ZIP_FLAG_CASE_SENSITIVE = 0x0100, |     MZ_ZIP_FLAG_CASE_SENSITIVE = 0x0100, | ||||||
|     MZ_ZIP_FLAG_IGNORE_PATH = 0x0200, |     MZ_ZIP_FLAG_IGNORE_PATH = 0x0200, | ||||||
|     MZ_ZIP_FLAG_COMPRESSED_DATA = 0x0400, |     MZ_ZIP_FLAG_COMPRESSED_DATA = 0x0400, | ||||||
| @@ -102,8 +100,7 @@ typedef enum | |||||||
|     MZ_ZIP_FLAG_ASCII_FILENAME = 0x10000 |     MZ_ZIP_FLAG_ASCII_FILENAME = 0x10000 | ||||||
| } mz_zip_flags; | } mz_zip_flags; | ||||||
|  |  | ||||||
| typedef enum | typedef enum { | ||||||
| { |  | ||||||
|     MZ_ZIP_TYPE_INVALID = 0, |     MZ_ZIP_TYPE_INVALID = 0, | ||||||
|     MZ_ZIP_TYPE_USER, |     MZ_ZIP_TYPE_USER, | ||||||
|     MZ_ZIP_TYPE_MEMORY, |     MZ_ZIP_TYPE_MEMORY, | ||||||
| @@ -114,8 +111,7 @@ typedef enum | |||||||
| } mz_zip_type; | } mz_zip_type; | ||||||
|  |  | ||||||
| /* miniz error codes. Be sure to update mz_zip_get_error_string() if you add or modify this enum. */ | /* miniz error codes. Be sure to update mz_zip_get_error_string() if you add or modify this enum. */ | ||||||
| typedef enum | typedef enum { | ||||||
| { |  | ||||||
|     MZ_ZIP_NO_ERROR = 0, |     MZ_ZIP_NO_ERROR = 0, | ||||||
|     MZ_ZIP_UNDEFINED_ERROR, |     MZ_ZIP_UNDEFINED_ERROR, | ||||||
|     MZ_ZIP_TOO_MANY_FILES, |     MZ_ZIP_TOO_MANY_FILES, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user