Commit Graph

39 Commits

Author SHA1 Message Date
Martin
8714fd3cd8 Format code with clang-format 2024-05-16 21:24:56 +02:00
Nyq
b0af33a61b
Update miniz_tdef.c to enable compiling in forced-C++ mode
Summary:
Merged definition of static const mz_uint s_tdefl_num_probes[11] with its declaration to avoid compilation error when compiling in forced-C++mode

Details:
When miniz_tdef.c is compiled in C++ mode (either by forcing the compiler to treat the input as C++ or by renaming the file into miniz.cpp), MSVC17 produces the following error:
```
miniz_tdef.cpp(2113,22): error C2086: 'const mz_uint s_tdefl_num_probes[11]': redefinition
miniz_tdef.cpp(1254,22): message : see declaration of 's_tdefl_num_probes'
```
This happens because in miniz_tdef.c we have the following:

```
/*Line 606:*/ static const mz_uint s_tdefl_num_probes[11];
/*Line 1465:*/ static const mz_uint s_tdefl_num_probes[11] = { 0, 1, 6, 32, 16, 32, 128, 256, 512, 768, 1500 };
```
While miniz_tdef.c is a C source file and not C++, sometimes it is used in C++ projects where settings are such that mixed C/C++ compilation is not allowed and all input source files are treated as forced C++. So there would be no harm to make a small adjustment so that the source code is conformant with both C and C++ requirements.

There are two ways it can be done:
Option 1: change line 606 from `static const mz_uint s_tdefl_num_probes[11];` to `extern const mz_uint s_tdefl_num_probes[11];`
Option2: eliminate line 1465 entirely and move line 2113 into line 1254 so that the code looks like this:
```
/*Line 606:*/ static const mz_uint s_tdefl_num_probes[11] = { 0, 1, 6, 32, 16, 32, 128, 256, 512, 768, 1500 };
/*Line 1465:*/ //Nothing here
```
Either option works for both C and C++ and really there is no harm in simply moving the full definition up like in option B and avoid duplication.

This change implements option B.
2023-08-15 04:50:07 -04:00
Andrey Akhmichin
ab052e6e58
Fix variable declaration. 2022-11-06 14:55:25 +05:00
Martin Raiber
78ef92043c
Merge pull request #237 from jodavaho/dev/fix_shadow_warning
Fix for n shadows variable
2022-08-25 22:01:46 +02:00
systoolz
a2b5326d86
missing const in declaration 2022-06-10 22:17:21 +07:00
Josh Vander Hook
8db69b6b59 Fix for n shadows variable 2022-05-19 11:24:55 -07:00
Martin Raiber
5c9c89509c
Merge pull request #231 from nedelec/master
Fixed alignment problems on MacOS
2022-05-08 16:48:02 +02:00
Martin Raiber
719967dc82
Merge pull request #225 from randy408/zlib_flevel
deflate: write zlib FLEVEL based on compression level
2022-05-08 16:46:36 +02:00
Martin Raiber
144c351f34
Update miniz_tdef.c
Co-authored-by: Alexander Borsuk <170263+biodranik@users.noreply.github.com>
2022-05-06 21:30:08 +02:00
Martin Raiber
bc77ea1017
Update miniz_tdef.c
Co-authored-by: Alexander Borsuk <170263+biodranik@users.noreply.github.com>
2022-05-06 21:30:02 +02:00
Randy
7c459c8a05
Update miniz_tdef.c
Co-authored-by: Alexander Borsuk <170263+biodranik@users.noreply.github.com>
2022-05-06 05:01:09 +02:00
Francois Nedelec
e7d0e216d5 Fixed alignment problems on MacOS 2022-04-01 14:34:04 +01:00
Andrius Mitkus
71ba5d12d6 Avoid NULL ptr arithmetic UB 2022-02-09 09:48:30 +03:00
Randy
cd1dc96d27 deflate: write zlib FLEVEL based on compression level 2022-02-08 23:24:02 +01:00
Martin
12b78b6d5a Fix function definitions
Fix function definitions tdefl_compressor_alloc(void) and
tinfl_decompressor_alloc(void) to not accept any amount of arguments.
2021-11-28 18:36:40 +01:00
Martin Raiber
82d6810a38
Merge pull request #193 from ccawley2011/no-inflate-deflate
Add MINIZ_NO_DEFLATE_APIS and MINIZ_NO_INFLATE_APIS
2021-11-11 21:36:53 +01:00
Cameron Cawley
9b89689723 Add MINIZ_NO_DEFLATE_APIS and MINIZ_NO_INFLATE_APIS 2021-07-20 20:19:32 +01:00
Cameron Cawley
78ae375016 Fix "'&array' may not produce intended result" warnings with OpenWatcom
Co-authored-by: sezero <sezero@users.noreply.github.com>
2021-07-20 18:08:11 +01:00
Martin Raiber
0c905aec41
Merge pull request #169 from ashtul/patch-1
remove redundant condition
2021-06-27 21:28:00 +02:00
Andre Maroneze
cf2833fdc1 avoid use of uninitialized value in tdefl_record_literal
In tdefl_record_literal, the following expression may read an uninitialized
value in the m_pLZ_flags field:

*d->m_pLZ_flags = (mz_uint8)(*d->m_pLZ_flags >> 1);

By explicitly initializing it, we avoid possible undefined behaviors.
Issue found with Frama-C.
2021-05-25 15:23:39 +02:00
ariel shtul
8410f3c640 remove redundant condition
L#1067 asserts that (match_len >= TDEFL_MIN_MATCH_LEN)
2020-11-01 12:02:06 +02:00
tamasmeszaros
d57872c77a Fix for older cmake versions and build of examples. 2019-06-03 10:02:13 +02:00
Dmitry Eremin-Solenikov
d31e119d4d Move comp/decomp alloc/free prototypes under guarding #ifndef
Function implemenations are already guarded by #ifndef MZ_NO_MALLOC, so
let's put prototypes under the same #ifndef. Also, while we are at it,
make those prototypes standard-compliant by adding void argument.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
2019-01-17 12:52:11 +03:00
Martin
407d298c14 Remove inline for c90 support 2018-11-05 18:32:42 +01:00
Martin
53bfef515c More instances of memcpy instead of cast and use memcpy per default 2018-10-27 17:14:33 +02:00
Jason Rohrer
02c51d3662 Fixed loads of uninitilized value errors found with Valgrind by memsetting m_dict to 0 in tdefl_init. 2017-08-28 18:28:14 -07:00
Martin
84e8458de0 Option to use memcpy for unaligned data access 2017-05-18 18:47:09 +02:00
Mario Cianciolo
a0786b126d Fix PNG height
Fixed array index where to store image height.
PNG files made using `tdefl_write_image_to_png_file_in_memory_ex()` were very tall, with a huge empty area at the end.
Since `pnghdr[22]` was assigned twice, I changed indices to store height exactly in the way width is stored (two consecutive swapped bytes). Now PNG file height is correct.
2017-04-30 23:13:09 +02:00
Michał Janiszewski
a6a989cc18 clang-format the sources 2017-03-23 08:50:08 +01:00
Martin
1c6ca868d7 Fix compilation with the various omission compile definitions 2017-03-13 19:38:42 +01:00
Martin
3b7ee5aea5 Fix compile warnings 2017-01-19 15:53:53 +01:00
Martin
4c36ab0230 Rerun clang-format 2017-01-03 01:30:38 +01:00
Martin
8e30365e91 Fix compile issues with "gcc -ansi" 2016-11-27 22:19:38 +01:00
Martin
224d207ce8 MiniZ ZIP64 was part of valve vogl which is MIT licensed 2016-11-21 18:17:47 +01:00
Matthew Sitton
3979a6de1f And finally Integrate vogl changes. 2016-06-25 12:13:28 -05:00
Matthew Sitton
11f1380c45 Some more formatting issues. 2016-06-25 12:03:49 -05:00
Matthew Sitton
d650d15974 Add vogl .clang-format and reformat library source. 2016-06-25 09:03:56 -05:00
Matthew Sitton
baa0e214e7 Add v1.16 beta r1 changes. 2016-06-25 08:02:20 -05:00
Matthew Sitton
724de0bb0f Separate the into multiple files similar to the vogl zip64 version of the library.
If anyone wants to have a minified version of if a script could be written to do this automatically.
2016-06-25 06:43:30 -05:00