koffi 2.3.6-beta.6 → 2.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/package.json +2 -2
- package/src/cnoke/cnoke.js +3 -7
- package/src/cnoke/src/builder.js +9 -6
- package/src/cnoke/src/index.js +2 -2
- package/src/koffi/build/2.3.7/koffi_darwin_arm64/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_darwin_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_freebsd_arm64/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_freebsd_ia32/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_freebsd_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_linux_arm32hf/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_linux_arm64/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_linux_ia32/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_linux_riscv64hf64/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_linux_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_openbsd_ia32/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_openbsd_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_win32_arm64/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_win32_ia32/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_win32_x64/koffi.node +0 -0
- package/src/koffi/src/ffi.cc +2 -2
- package/src/koffi/src/index.d.ts +2 -2
- package/src/koffi/src/index.js +1 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_darwin_arm64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_darwin_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_freebsd_arm64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_freebsd_ia32/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_freebsd_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_linux_arm32hf/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_linux_arm64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_linux_ia32/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_linux_riscv64hf64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_linux_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_openbsd_ia32/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_openbsd_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_win32_arm64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_win32_arm64/koffi.pdb +0 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_win32_ia32/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_win32_ia32/koffi.pdb +0 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_win32_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_win32_x64/koffi.pdb +0 -0
- package/vendor/brotli/BUILD +0 -144
- package/vendor/brotli/CMakeLists.txt +0 -421
- package/vendor/brotli/CONTRIBUTING.md +0 -27
- package/vendor/brotli/LICENSE +0 -19
- package/vendor/brotli/MANIFEST.in +0 -17
- package/vendor/brotli/Makefile +0 -55
- package/vendor/brotli/Makefile.am +0 -38
- package/vendor/brotli/README +0 -15
- package/vendor/brotli/README.md +0 -104
- package/vendor/brotli/WORKSPACE +0 -21
- package/vendor/brotli/bootstrap +0 -35
- package/vendor/brotli/c/common/constants.c +0 -15
- package/vendor/brotli/c/common/constants.h +0 -200
- package/vendor/brotli/c/common/context.c +0 -156
- package/vendor/brotli/c/common/context.h +0 -113
- package/vendor/brotli/c/common/dictionary.c +0 -5914
- package/vendor/brotli/c/common/dictionary.h +0 -64
- package/vendor/brotli/c/common/platform.c +0 -22
- package/vendor/brotli/c/common/platform.h +0 -596
- package/vendor/brotli/c/common/transform.c +0 -291
- package/vendor/brotli/c/common/transform.h +0 -85
- package/vendor/brotli/c/common/version.h +0 -26
- package/vendor/brotli/c/dec/bit_reader.c +0 -76
- package/vendor/brotli/c/dec/bit_reader.h +0 -351
- package/vendor/brotli/c/dec/decode.c +0 -2608
- package/vendor/brotli/c/dec/huffman.c +0 -339
- package/vendor/brotli/c/dec/huffman.h +0 -121
- package/vendor/brotli/c/dec/prefix.h +0 -732
- package/vendor/brotli/c/dec/state.c +0 -159
- package/vendor/brotli/c/dec/state.h +0 -365
- package/vendor/brotli/c/enc/backward_references.c +0 -145
- package/vendor/brotli/c/enc/backward_references.h +0 -39
- package/vendor/brotli/c/enc/backward_references_hq.c +0 -843
- package/vendor/brotli/c/enc/backward_references_hq.h +0 -95
- package/vendor/brotli/c/enc/backward_references_inc.h +0 -163
- package/vendor/brotli/c/enc/bit_cost.c +0 -35
- package/vendor/brotli/c/enc/bit_cost.h +0 -63
- package/vendor/brotli/c/enc/bit_cost_inc.h +0 -127
- package/vendor/brotli/c/enc/block_encoder_inc.h +0 -34
- package/vendor/brotli/c/enc/block_splitter.c +0 -194
- package/vendor/brotli/c/enc/block_splitter.h +0 -51
- package/vendor/brotli/c/enc/block_splitter_inc.h +0 -440
- package/vendor/brotli/c/enc/brotli_bit_stream.c +0 -1314
- package/vendor/brotli/c/enc/brotli_bit_stream.h +0 -84
- package/vendor/brotli/c/enc/cluster.c +0 -56
- package/vendor/brotli/c/enc/cluster.h +0 -48
- package/vendor/brotli/c/enc/cluster_inc.h +0 -320
- package/vendor/brotli/c/enc/command.c +0 -28
- package/vendor/brotli/c/enc/command.h +0 -190
- package/vendor/brotli/c/enc/compress_fragment.c +0 -790
- package/vendor/brotli/c/enc/compress_fragment.h +0 -61
- package/vendor/brotli/c/enc/compress_fragment_two_pass.c +0 -645
- package/vendor/brotli/c/enc/compress_fragment_two_pass.h +0 -54
- package/vendor/brotli/c/enc/dictionary_hash.c +0 -1846
- package/vendor/brotli/c/enc/dictionary_hash.h +0 -25
- package/vendor/brotli/c/enc/encode.c +0 -1927
- package/vendor/brotli/c/enc/encoder_dict.c +0 -33
- package/vendor/brotli/c/enc/encoder_dict.h +0 -43
- package/vendor/brotli/c/enc/entropy_encode.c +0 -503
- package/vendor/brotli/c/enc/entropy_encode.h +0 -122
- package/vendor/brotli/c/enc/entropy_encode_static.h +0 -539
- package/vendor/brotli/c/enc/fast_log.c +0 -105
- package/vendor/brotli/c/enc/fast_log.h +0 -66
- package/vendor/brotli/c/enc/find_match_length.h +0 -79
- package/vendor/brotli/c/enc/hash.h +0 -488
- package/vendor/brotli/c/enc/hash_composite_inc.h +0 -125
- package/vendor/brotli/c/enc/hash_forgetful_chain_inc.h +0 -293
- package/vendor/brotli/c/enc/hash_longest_match64_inc.h +0 -267
- package/vendor/brotli/c/enc/hash_longest_match_inc.h +0 -262
- package/vendor/brotli/c/enc/hash_longest_match_quickly_inc.h +0 -266
- package/vendor/brotli/c/enc/hash_rolling_inc.h +0 -212
- package/vendor/brotli/c/enc/hash_to_binary_tree_inc.h +0 -329
- package/vendor/brotli/c/enc/histogram.c +0 -100
- package/vendor/brotli/c/enc/histogram.h +0 -63
- package/vendor/brotli/c/enc/histogram_inc.h +0 -51
- package/vendor/brotli/c/enc/literal_cost.c +0 -175
- package/vendor/brotli/c/enc/literal_cost.h +0 -30
- package/vendor/brotli/c/enc/memory.c +0 -170
- package/vendor/brotli/c/enc/memory.h +0 -114
- package/vendor/brotli/c/enc/metablock.c +0 -663
- package/vendor/brotli/c/enc/metablock.h +0 -105
- package/vendor/brotli/c/enc/metablock_inc.h +0 -183
- package/vendor/brotli/c/enc/params.h +0 -46
- package/vendor/brotli/c/enc/prefix.h +0 -53
- package/vendor/brotli/c/enc/quality.h +0 -165
- package/vendor/brotli/c/enc/ringbuffer.h +0 -167
- package/vendor/brotli/c/enc/static_dict.c +0 -486
- package/vendor/brotli/c/enc/static_dict.h +0 -40
- package/vendor/brotli/c/enc/static_dict_lut.h +0 -5864
- package/vendor/brotli/c/enc/utf8_util.c +0 -85
- package/vendor/brotli/c/enc/utf8_util.h +0 -32
- package/vendor/brotli/c/enc/write_bits.h +0 -87
- package/vendor/brotli/c/include/brotli/decode.h +0 -344
- package/vendor/brotli/c/include/brotli/encode.h +0 -448
- package/vendor/brotli/c/include/brotli/port.h +0 -288
- package/vendor/brotli/c/include/brotli/types.h +0 -83
- package/vendor/brotli/c/tools/brotli.c +0 -1116
- package/vendor/brotli/c/tools/brotli.md +0 -107
- package/vendor/brotli/compiler_config_setting.bzl +0 -28
- package/vendor/brotli/configure +0 -8
- package/vendor/brotli/configure-cmake +0 -318
- package/vendor/brotli/configure.ac +0 -14
- package/vendor/brotli/docs/brotli.1 +0 -132
- package/vendor/brotli/docs/constants.h.3 +0 -47
- package/vendor/brotli/docs/decode.h.3 +0 -415
- package/vendor/brotli/docs/encode.h.3 +0 -586
- package/vendor/brotli/docs/types.h.3 +0 -117
- package/vendor/brotli/premake5.lua +0 -78
- package/vendor/brotli/python/Makefile +0 -57
- package/vendor/brotli/python/README.md +0 -54
- package/vendor/brotli/python/_brotli.cc +0 -753
- package/vendor/brotli/python/bro.py +0 -160
- package/vendor/brotli/python/brotli.py +0 -56
- package/vendor/brotli/python/tests/__init__.py +0 -0
- package/vendor/brotli/python/tests/_test_utils.py +0 -112
- package/vendor/brotli/python/tests/bro_test.py +0 -102
- package/vendor/brotli/python/tests/compress_test.py +0 -41
- package/vendor/brotli/python/tests/compressor_test.py +0 -94
- package/vendor/brotli/python/tests/decompress_test.py +0 -42
- package/vendor/brotli/python/tests/decompressor_test.py +0 -59
- package/vendor/brotli/scripts/libbrotlicommon.pc.in +0 -11
- package/vendor/brotli/scripts/libbrotlidec.pc.in +0 -12
- package/vendor/brotli/scripts/libbrotlienc.pc.in +0 -12
- package/vendor/brotli/scripts/sources.lst +0 -104
- package/vendor/brotli/setup.cfg +0 -5
- package/vendor/brotli/setup.py +0 -293
- package/vendor/brotli/tests/Makefile +0 -17
- package/vendor/brotli/tests/compatibility_test.sh +0 -25
- package/vendor/brotli/tests/roundtrip_test.sh +0 -36
- package/vendor/brotli/tests/run-compatibility-test.cmake +0 -31
- package/vendor/brotli/tests/run-roundtrip-test.cmake +0 -36
- package/vendor/brotli/tests/testdata/empty +0 -0
- package/vendor/brotli/tests/testdata/empty.compressed +0 -1
- package/vendor/brotli/tests/testdata/ukkonooa +0 -1
- package/vendor/brotli/tests/testdata/ukkonooa.compressed +0 -0
- package/vendor/dragonbox/CMakeLists.txt +0 -123
- package/vendor/dragonbox/LICENSE-Apache2-LLVM +0 -218
- package/vendor/dragonbox/LICENSE-Boost +0 -23
- package/vendor/dragonbox/README.md +0 -277
- package/vendor/dragonbox/cmake/dragonboxConfig.cmake +0 -1
- package/vendor/dragonbox/include/dragonbox/dragonbox.h +0 -2674
- package/vendor/dragonbox/include/dragonbox/dragonbox_to_chars.h +0 -108
- package/vendor/dragonbox/other_files/Dragonbox.pdf +0 -0
- package/vendor/dragonbox/other_files/Dragonbox_old.pdf +0 -0
- package/vendor/dragonbox/other_files/milo_benchmark.png +0 -0
- package/vendor/dragonbox/other_files/unknown_win64_vc2019.html +0 -540
- package/vendor/dragonbox/other_files/unknown_win64_vc2019_randomdigit_time.png +0 -0
- package/vendor/dragonbox/source/dragonbox_to_chars.cpp +0 -303
- package/vendor/dragonbox/subproject/3rdparty/grisu_exact/CMakeLists.txt +0 -24
- package/vendor/dragonbox/subproject/3rdparty/grisu_exact/fp_to_chars.cpp +0 -238
- package/vendor/dragonbox/subproject/3rdparty/grisu_exact/fp_to_chars.h +0 -95
- package/vendor/dragonbox/subproject/3rdparty/grisu_exact/grisu_exact.h +0 -2666
- package/vendor/dragonbox/subproject/3rdparty/ryu/CMakeLists.txt +0 -16
- package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/common.h +0 -114
- package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/d2s.c +0 -509
- package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/d2s_full_table.h +0 -367
- package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/d2s_intrinsics.h +0 -357
- package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/digit_table.h +0 -35
- package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/f2s.c +0 -345
- package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/f2s_full_table.h +0 -55
- package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/f2s_intrinsics.h +0 -128
- package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/ryu.h +0 -46
- package/vendor/dragonbox/subproject/3rdparty/schubfach/CMakeLists.txt +0 -22
- package/vendor/dragonbox/subproject/3rdparty/schubfach/schubfach_32.cc +0 -699
- package/vendor/dragonbox/subproject/3rdparty/schubfach/schubfach_32.h +0 -31
- package/vendor/dragonbox/subproject/3rdparty/schubfach/schubfach_64.cc +0 -1354
- package/vendor/dragonbox/subproject/3rdparty/schubfach/schubfach_64.h +0 -31
- package/vendor/dragonbox/subproject/3rdparty/shaded_plots/example_shaded_plots.m +0 -68
- package/vendor/dragonbox/subproject/3rdparty/shaded_plots/license.txt +0 -25
- package/vendor/dragonbox/subproject/3rdparty/shaded_plots/plot_distribution.m +0 -92
- package/vendor/dragonbox/subproject/3rdparty/shaded_plots/plot_distribution_prctile.m +0 -121
- package/vendor/dragonbox/subproject/3rdparty/shaded_plots/plot_histogram_shaded.m +0 -99
- package/vendor/dragonbox/subproject/3rdparty/shaded_plots/plot_shaded.m +0 -93
- package/vendor/dragonbox/subproject/benchmark/CMakeLists.txt +0 -65
- package/vendor/dragonbox/subproject/benchmark/include/benchmark.h +0 -40
- package/vendor/dragonbox/subproject/benchmark/matlab/plot_benchmarks.m +0 -22
- package/vendor/dragonbox/subproject/benchmark/matlab/plot_digit_benchmark.m +0 -78
- package/vendor/dragonbox/subproject/benchmark/matlab/plot_uniform_benchmark.m +0 -95
- package/vendor/dragonbox/subproject/benchmark/results/digits_benchmark_binary32_clang.png +0 -0
- package/vendor/dragonbox/subproject/benchmark/results/digits_benchmark_binary32_msvc.png +0 -0
- package/vendor/dragonbox/subproject/benchmark/results/digits_benchmark_binary64_clang.png +0 -0
- package/vendor/dragonbox/subproject/benchmark/results/digits_benchmark_binary64_msvc.png +0 -0
- package/vendor/dragonbox/subproject/benchmark/results/uniform_benchmark_binary32_clang.png +0 -0
- package/vendor/dragonbox/subproject/benchmark/results/uniform_benchmark_binary32_msvc.png +0 -0
- package/vendor/dragonbox/subproject/benchmark/results/uniform_benchmark_binary64_clang.png +0 -0
- package/vendor/dragonbox/subproject/benchmark/results/uniform_benchmark_binary64_msvc.png +0 -0
- package/vendor/dragonbox/subproject/benchmark/source/benchmark.cpp +0 -238
- package/vendor/dragonbox/subproject/benchmark/source/dragonbox.cpp +0 -30
- package/vendor/dragonbox/subproject/benchmark/source/grisu_exact.cpp +0 -36
- package/vendor/dragonbox/subproject/benchmark/source/ryu.cpp +0 -27
- package/vendor/dragonbox/subproject/benchmark/source/schubfach.cpp +0 -31
- package/vendor/dragonbox/subproject/common/CMakeLists.txt +0 -42
- package/vendor/dragonbox/subproject/common/include/best_rational_approx.h +0 -97
- package/vendor/dragonbox/subproject/common/include/big_uint.h +0 -218
- package/vendor/dragonbox/subproject/common/include/continued_fractions.h +0 -174
- package/vendor/dragonbox/subproject/common/include/good_rational_approx.h +0 -267
- package/vendor/dragonbox/subproject/common/include/random_float.h +0 -182
- package/vendor/dragonbox/subproject/common/include/rational_continued_fractions.h +0 -57
- package/vendor/dragonbox/subproject/common/source/big_uint.cpp +0 -602
- package/vendor/dragonbox/subproject/meta/CMakeLists.txt +0 -41
- package/vendor/dragonbox/subproject/meta/results/binary32_generated_cache.txt +0 -82
- package/vendor/dragonbox/subproject/meta/results/binary64_compressed_cache_error_table.txt +0 -10
- package/vendor/dragonbox/subproject/meta/results/binary64_generated_cache.txt +0 -623
- package/vendor/dragonbox/subproject/meta/source/generate_cache.cpp +0 -126
- package/vendor/dragonbox/subproject/meta/source/live_test.cpp +0 -81
- package/vendor/dragonbox/subproject/meta/source/perf_test.cpp +0 -104
- package/vendor/dragonbox/subproject/meta/source/sandbox.cpp +0 -20
- package/vendor/dragonbox/subproject/test/CMakeLists.txt +0 -70
- package/vendor/dragonbox/subproject/test/results/binary32.csv +0 -255
- package/vendor/dragonbox/subproject/test/results/binary64.csv +0 -2047
- package/vendor/dragonbox/subproject/test/results/plot_required_bits.m +0 -18
- package/vendor/dragonbox/subproject/test/source/test_all_shorter_interval_cases.cpp +0 -88
- package/vendor/dragonbox/subproject/test/source/uniform_random_test.cpp +0 -95
- package/vendor/dragonbox/subproject/test/source/verify_cache_precision.cpp +0 -338
- package/vendor/dragonbox/subproject/test/source/verify_compressed_cache.cpp +0 -154
- package/vendor/dragonbox/subproject/test/source/verify_fast_multiplication.cpp +0 -168
- package/vendor/dragonbox/subproject/test/source/verify_log_computation.cpp +0 -251
- package/vendor/dragonbox/subproject/test/source/verify_magic_division.cpp +0 -113
- package/vendor/miniz/ChangeLog.md +0 -239
- package/vendor/miniz/LICENSE +0 -22
- package/vendor/miniz/examples/example1.c +0 -105
- package/vendor/miniz/examples/example2.c +0 -164
- package/vendor/miniz/examples/example3.c +0 -269
- package/vendor/miniz/examples/example4.c +0 -102
- package/vendor/miniz/examples/example5.c +0 -327
- package/vendor/miniz/examples/example6.c +0 -166
- package/vendor/miniz/miniz.c +0 -7835
- package/vendor/miniz/miniz.h +0 -1422
- package/vendor/miniz/readme.md +0 -46
- /package/src/koffi/build/{2.3.6-beta.6 → 2.3.7}/koffi_win32_arm64/koffi.exp +0 -0
- /package/src/koffi/build/{2.3.6-beta.6 → 2.3.7}/koffi_win32_arm64/koffi.lib +0 -0
- /package/src/koffi/build/{2.3.6-beta.6 → 2.3.7}/koffi_win32_ia32/koffi.exp +0 -0
- /package/src/koffi/build/{2.3.6-beta.6 → 2.3.7}/koffi_win32_ia32/koffi.lib +0 -0
- /package/src/koffi/build/{2.3.6-beta.6 → 2.3.7}/koffi_win32_x64/koffi.exp +0 -0
- /package/src/koffi/build/{2.3.6-beta.6 → 2.3.7}/koffi_win32_x64/koffi.lib +0 -0
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/* NOLINT(build/header_guard) */
|
|
2
|
-
/* Copyright 2013 Google Inc. All Rights Reserved.
|
|
3
|
-
|
|
4
|
-
Distributed under MIT license.
|
|
5
|
-
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/* template parameters: Histogram, DATA_SIZE, DataType */
|
|
9
|
-
|
|
10
|
-
/* A simple container for histograms of data in blocks. */
|
|
11
|
-
|
|
12
|
-
typedef struct FN(Histogram) {
|
|
13
|
-
uint32_t data_[DATA_SIZE];
|
|
14
|
-
size_t total_count_;
|
|
15
|
-
double bit_cost_;
|
|
16
|
-
} FN(Histogram);
|
|
17
|
-
|
|
18
|
-
static BROTLI_INLINE void FN(HistogramClear)(FN(Histogram)* self) {
|
|
19
|
-
memset(self->data_, 0, sizeof(self->data_));
|
|
20
|
-
self->total_count_ = 0;
|
|
21
|
-
self->bit_cost_ = HUGE_VAL;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
static BROTLI_INLINE void FN(ClearHistograms)(
|
|
25
|
-
FN(Histogram)* array, size_t length) {
|
|
26
|
-
size_t i;
|
|
27
|
-
for (i = 0; i < length; ++i) FN(HistogramClear)(array + i);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
static BROTLI_INLINE void FN(HistogramAdd)(FN(Histogram)* self, size_t val) {
|
|
31
|
-
++self->data_[val];
|
|
32
|
-
++self->total_count_;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
static BROTLI_INLINE void FN(HistogramAddVector)(FN(Histogram)* self,
|
|
36
|
-
const DataType* p, size_t n) {
|
|
37
|
-
self->total_count_ += n;
|
|
38
|
-
n += 1;
|
|
39
|
-
while (--n) ++self->data_[*p++];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
static BROTLI_INLINE void FN(HistogramAddHistogram)(FN(Histogram)* self,
|
|
43
|
-
const FN(Histogram)* v) {
|
|
44
|
-
size_t i;
|
|
45
|
-
self->total_count_ += v->total_count_;
|
|
46
|
-
for (i = 0; i < DATA_SIZE; ++i) {
|
|
47
|
-
self->data_[i] += v->data_[i];
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
static BROTLI_INLINE size_t FN(HistogramDataSize)(void) { return DATA_SIZE; }
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
/* Copyright 2013 Google Inc. All Rights Reserved.
|
|
2
|
-
|
|
3
|
-
Distributed under MIT license.
|
|
4
|
-
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/* Literal cost model to allow backward reference replacement to be efficient.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
#include "./literal_cost.h"
|
|
11
|
-
|
|
12
|
-
#include "../common/platform.h"
|
|
13
|
-
#include <brotli/types.h>
|
|
14
|
-
#include "./fast_log.h"
|
|
15
|
-
#include "./utf8_util.h"
|
|
16
|
-
|
|
17
|
-
#if defined(__cplusplus) || defined(c_plusplus)
|
|
18
|
-
extern "C" {
|
|
19
|
-
#endif
|
|
20
|
-
|
|
21
|
-
static size_t UTF8Position(size_t last, size_t c, size_t clamp) {
|
|
22
|
-
if (c < 128) {
|
|
23
|
-
return 0; /* Next one is the 'Byte 1' again. */
|
|
24
|
-
} else if (c >= 192) { /* Next one is the 'Byte 2' of utf-8 encoding. */
|
|
25
|
-
return BROTLI_MIN(size_t, 1, clamp);
|
|
26
|
-
} else {
|
|
27
|
-
/* Let's decide over the last byte if this ends the sequence. */
|
|
28
|
-
if (last < 0xE0) {
|
|
29
|
-
return 0; /* Completed two or three byte coding. */
|
|
30
|
-
} else { /* Next one is the 'Byte 3' of utf-8 encoding. */
|
|
31
|
-
return BROTLI_MIN(size_t, 2, clamp);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
static size_t DecideMultiByteStatsLevel(size_t pos, size_t len, size_t mask,
|
|
37
|
-
const uint8_t* data) {
|
|
38
|
-
size_t counts[3] = { 0 };
|
|
39
|
-
size_t max_utf8 = 1; /* should be 2, but 1 compresses better. */
|
|
40
|
-
size_t last_c = 0;
|
|
41
|
-
size_t i;
|
|
42
|
-
for (i = 0; i < len; ++i) {
|
|
43
|
-
size_t c = data[(pos + i) & mask];
|
|
44
|
-
++counts[UTF8Position(last_c, c, 2)];
|
|
45
|
-
last_c = c;
|
|
46
|
-
}
|
|
47
|
-
if (counts[2] < 500) {
|
|
48
|
-
max_utf8 = 1;
|
|
49
|
-
}
|
|
50
|
-
if (counts[1] + counts[2] < 25) {
|
|
51
|
-
max_utf8 = 0;
|
|
52
|
-
}
|
|
53
|
-
return max_utf8;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
static void EstimateBitCostsForLiteralsUTF8(size_t pos, size_t len, size_t mask,
|
|
57
|
-
const uint8_t* data, float* cost) {
|
|
58
|
-
/* max_utf8 is 0 (normal ASCII single byte modeling),
|
|
59
|
-
1 (for 2-byte UTF-8 modeling), or 2 (for 3-byte UTF-8 modeling). */
|
|
60
|
-
const size_t max_utf8 = DecideMultiByteStatsLevel(pos, len, mask, data);
|
|
61
|
-
size_t histogram[3][256] = { { 0 } };
|
|
62
|
-
size_t window_half = 495;
|
|
63
|
-
size_t in_window = BROTLI_MIN(size_t, window_half, len);
|
|
64
|
-
size_t in_window_utf8[3] = { 0 };
|
|
65
|
-
|
|
66
|
-
size_t i;
|
|
67
|
-
{ /* Bootstrap histograms. */
|
|
68
|
-
size_t last_c = 0;
|
|
69
|
-
size_t utf8_pos = 0;
|
|
70
|
-
for (i = 0; i < in_window; ++i) {
|
|
71
|
-
size_t c = data[(pos + i) & mask];
|
|
72
|
-
++histogram[utf8_pos][c];
|
|
73
|
-
++in_window_utf8[utf8_pos];
|
|
74
|
-
utf8_pos = UTF8Position(last_c, c, max_utf8);
|
|
75
|
-
last_c = c;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/* Compute bit costs with sliding window. */
|
|
80
|
-
for (i = 0; i < len; ++i) {
|
|
81
|
-
if (i >= window_half) {
|
|
82
|
-
/* Remove a byte in the past. */
|
|
83
|
-
size_t c =
|
|
84
|
-
i < window_half + 1 ? 0 : data[(pos + i - window_half - 1) & mask];
|
|
85
|
-
size_t last_c =
|
|
86
|
-
i < window_half + 2 ? 0 : data[(pos + i - window_half - 2) & mask];
|
|
87
|
-
size_t utf8_pos2 = UTF8Position(last_c, c, max_utf8);
|
|
88
|
-
--histogram[utf8_pos2][data[(pos + i - window_half) & mask]];
|
|
89
|
-
--in_window_utf8[utf8_pos2];
|
|
90
|
-
}
|
|
91
|
-
if (i + window_half < len) {
|
|
92
|
-
/* Add a byte in the future. */
|
|
93
|
-
size_t c = data[(pos + i + window_half - 1) & mask];
|
|
94
|
-
size_t last_c = data[(pos + i + window_half - 2) & mask];
|
|
95
|
-
size_t utf8_pos2 = UTF8Position(last_c, c, max_utf8);
|
|
96
|
-
++histogram[utf8_pos2][data[(pos + i + window_half) & mask]];
|
|
97
|
-
++in_window_utf8[utf8_pos2];
|
|
98
|
-
}
|
|
99
|
-
{
|
|
100
|
-
size_t c = i < 1 ? 0 : data[(pos + i - 1) & mask];
|
|
101
|
-
size_t last_c = i < 2 ? 0 : data[(pos + i - 2) & mask];
|
|
102
|
-
size_t utf8_pos = UTF8Position(last_c, c, max_utf8);
|
|
103
|
-
size_t masked_pos = (pos + i) & mask;
|
|
104
|
-
size_t histo = histogram[utf8_pos][data[masked_pos]];
|
|
105
|
-
double lit_cost;
|
|
106
|
-
if (histo == 0) {
|
|
107
|
-
histo = 1;
|
|
108
|
-
}
|
|
109
|
-
lit_cost = FastLog2(in_window_utf8[utf8_pos]) - FastLog2(histo);
|
|
110
|
-
lit_cost += 0.02905;
|
|
111
|
-
if (lit_cost < 1.0) {
|
|
112
|
-
lit_cost *= 0.5;
|
|
113
|
-
lit_cost += 0.5;
|
|
114
|
-
}
|
|
115
|
-
/* Make the first bytes more expensive -- seems to help, not sure why.
|
|
116
|
-
Perhaps because the entropy source is changing its properties
|
|
117
|
-
rapidly in the beginning of the file, perhaps because the beginning
|
|
118
|
-
of the data is a statistical "anomaly". */
|
|
119
|
-
if (i < 2000) {
|
|
120
|
-
lit_cost += 0.7 - ((double)(2000 - i) / 2000.0 * 0.35);
|
|
121
|
-
}
|
|
122
|
-
cost[i] = (float)lit_cost;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
void BrotliEstimateBitCostsForLiterals(size_t pos, size_t len, size_t mask,
|
|
128
|
-
const uint8_t* data, float* cost) {
|
|
129
|
-
if (BrotliIsMostlyUTF8(data, pos, mask, len, kMinUTF8Ratio)) {
|
|
130
|
-
EstimateBitCostsForLiteralsUTF8(pos, len, mask, data, cost);
|
|
131
|
-
return;
|
|
132
|
-
} else {
|
|
133
|
-
size_t histogram[256] = { 0 };
|
|
134
|
-
size_t window_half = 2000;
|
|
135
|
-
size_t in_window = BROTLI_MIN(size_t, window_half, len);
|
|
136
|
-
|
|
137
|
-
/* Bootstrap histogram. */
|
|
138
|
-
size_t i;
|
|
139
|
-
for (i = 0; i < in_window; ++i) {
|
|
140
|
-
++histogram[data[(pos + i) & mask]];
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/* Compute bit costs with sliding window. */
|
|
144
|
-
for (i = 0; i < len; ++i) {
|
|
145
|
-
size_t histo;
|
|
146
|
-
if (i >= window_half) {
|
|
147
|
-
/* Remove a byte in the past. */
|
|
148
|
-
--histogram[data[(pos + i - window_half) & mask]];
|
|
149
|
-
--in_window;
|
|
150
|
-
}
|
|
151
|
-
if (i + window_half < len) {
|
|
152
|
-
/* Add a byte in the future. */
|
|
153
|
-
++histogram[data[(pos + i + window_half) & mask]];
|
|
154
|
-
++in_window;
|
|
155
|
-
}
|
|
156
|
-
histo = histogram[data[(pos + i) & mask]];
|
|
157
|
-
if (histo == 0) {
|
|
158
|
-
histo = 1;
|
|
159
|
-
}
|
|
160
|
-
{
|
|
161
|
-
double lit_cost = FastLog2(in_window) - FastLog2(histo);
|
|
162
|
-
lit_cost += 0.029;
|
|
163
|
-
if (lit_cost < 1.0) {
|
|
164
|
-
lit_cost *= 0.5;
|
|
165
|
-
lit_cost += 0.5;
|
|
166
|
-
}
|
|
167
|
-
cost[i] = (float)lit_cost;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
#if defined(__cplusplus) || defined(c_plusplus)
|
|
174
|
-
} /* extern "C" */
|
|
175
|
-
#endif
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/* Copyright 2013 Google Inc. All Rights Reserved.
|
|
2
|
-
|
|
3
|
-
Distributed under MIT license.
|
|
4
|
-
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/* Literal cost model to allow backward reference replacement to be efficient.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
#ifndef BROTLI_ENC_LITERAL_COST_H_
|
|
11
|
-
#define BROTLI_ENC_LITERAL_COST_H_
|
|
12
|
-
|
|
13
|
-
#include "../common/platform.h"
|
|
14
|
-
#include <brotli/types.h>
|
|
15
|
-
|
|
16
|
-
#if defined(__cplusplus) || defined(c_plusplus)
|
|
17
|
-
extern "C" {
|
|
18
|
-
#endif
|
|
19
|
-
|
|
20
|
-
/* Estimates how many bits the literals in the interval [pos, pos + len) in the
|
|
21
|
-
ring-buffer (data, mask) will take entropy coded and writes these estimates
|
|
22
|
-
to the cost[0..len) array. */
|
|
23
|
-
BROTLI_INTERNAL void BrotliEstimateBitCostsForLiterals(
|
|
24
|
-
size_t pos, size_t len, size_t mask, const uint8_t* data, float* cost);
|
|
25
|
-
|
|
26
|
-
#if defined(__cplusplus) || defined(c_plusplus)
|
|
27
|
-
} /* extern "C" */
|
|
28
|
-
#endif
|
|
29
|
-
|
|
30
|
-
#endif /* BROTLI_ENC_LITERAL_COST_H_ */
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
/* Copyright 2015 Google Inc. All Rights Reserved.
|
|
2
|
-
|
|
3
|
-
Distributed under MIT license.
|
|
4
|
-
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/* Algorithms for distributing the literals and commands of a metablock between
|
|
8
|
-
block types and contexts. */
|
|
9
|
-
|
|
10
|
-
#include "./memory.h"
|
|
11
|
-
|
|
12
|
-
#include <stdlib.h> /* exit, free, malloc */
|
|
13
|
-
#include <string.h> /* memcpy */
|
|
14
|
-
|
|
15
|
-
#include "../common/platform.h"
|
|
16
|
-
#include <brotli/types.h>
|
|
17
|
-
|
|
18
|
-
#if defined(__cplusplus) || defined(c_plusplus)
|
|
19
|
-
extern "C" {
|
|
20
|
-
#endif
|
|
21
|
-
|
|
22
|
-
#define MAX_PERM_ALLOCATED 128
|
|
23
|
-
#define MAX_NEW_ALLOCATED 64
|
|
24
|
-
#define MAX_NEW_FREED 64
|
|
25
|
-
|
|
26
|
-
#define PERM_ALLOCATED_OFFSET 0
|
|
27
|
-
#define NEW_ALLOCATED_OFFSET MAX_PERM_ALLOCATED
|
|
28
|
-
#define NEW_FREED_OFFSET (MAX_PERM_ALLOCATED + MAX_NEW_ALLOCATED)
|
|
29
|
-
|
|
30
|
-
void BrotliInitMemoryManager(
|
|
31
|
-
MemoryManager* m, brotli_alloc_func alloc_func, brotli_free_func free_func,
|
|
32
|
-
void* opaque) {
|
|
33
|
-
if (!alloc_func) {
|
|
34
|
-
m->alloc_func = BrotliDefaultAllocFunc;
|
|
35
|
-
m->free_func = BrotliDefaultFreeFunc;
|
|
36
|
-
m->opaque = 0;
|
|
37
|
-
} else {
|
|
38
|
-
m->alloc_func = alloc_func;
|
|
39
|
-
m->free_func = free_func;
|
|
40
|
-
m->opaque = opaque;
|
|
41
|
-
}
|
|
42
|
-
#if !defined(BROTLI_ENCODER_EXIT_ON_OOM)
|
|
43
|
-
m->is_oom = BROTLI_FALSE;
|
|
44
|
-
m->perm_allocated = 0;
|
|
45
|
-
m->new_allocated = 0;
|
|
46
|
-
m->new_freed = 0;
|
|
47
|
-
#endif /* BROTLI_ENCODER_EXIT_ON_OOM */
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
#if defined(BROTLI_ENCODER_EXIT_ON_OOM)
|
|
51
|
-
|
|
52
|
-
void* BrotliAllocate(MemoryManager* m, size_t n) {
|
|
53
|
-
void* result = m->alloc_func(m->opaque, n);
|
|
54
|
-
if (!result) exit(EXIT_FAILURE);
|
|
55
|
-
return result;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
void BrotliFree(MemoryManager* m, void* p) {
|
|
59
|
-
m->free_func(m->opaque, p);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
void BrotliWipeOutMemoryManager(MemoryManager* m) {
|
|
63
|
-
BROTLI_UNUSED(m);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
#else /* BROTLI_ENCODER_EXIT_ON_OOM */
|
|
67
|
-
|
|
68
|
-
static void SortPointers(void** items, const size_t n) {
|
|
69
|
-
/* Shell sort. */
|
|
70
|
-
static const size_t gaps[] = {23, 10, 4, 1};
|
|
71
|
-
int g = 0;
|
|
72
|
-
for (; g < 4; ++g) {
|
|
73
|
-
size_t gap = gaps[g];
|
|
74
|
-
size_t i;
|
|
75
|
-
for (i = gap; i < n; ++i) {
|
|
76
|
-
size_t j = i;
|
|
77
|
-
void* tmp = items[i];
|
|
78
|
-
for (; j >= gap && tmp < items[j - gap]; j -= gap) {
|
|
79
|
-
items[j] = items[j - gap];
|
|
80
|
-
}
|
|
81
|
-
items[j] = tmp;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
static size_t Annihilate(void** a, size_t a_len, void** b, size_t b_len) {
|
|
87
|
-
size_t a_read_index = 0;
|
|
88
|
-
size_t b_read_index = 0;
|
|
89
|
-
size_t a_write_index = 0;
|
|
90
|
-
size_t b_write_index = 0;
|
|
91
|
-
size_t annihilated = 0;
|
|
92
|
-
while (a_read_index < a_len && b_read_index < b_len) {
|
|
93
|
-
if (a[a_read_index] == b[b_read_index]) {
|
|
94
|
-
a_read_index++;
|
|
95
|
-
b_read_index++;
|
|
96
|
-
annihilated++;
|
|
97
|
-
} else if (a[a_read_index] < b[b_read_index]) {
|
|
98
|
-
a[a_write_index++] = a[a_read_index++];
|
|
99
|
-
} else {
|
|
100
|
-
b[b_write_index++] = b[b_read_index++];
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
while (a_read_index < a_len) a[a_write_index++] = a[a_read_index++];
|
|
104
|
-
while (b_read_index < b_len) b[b_write_index++] = b[b_read_index++];
|
|
105
|
-
return annihilated;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
static void CollectGarbagePointers(MemoryManager* m) {
|
|
109
|
-
size_t annihilated;
|
|
110
|
-
SortPointers(m->pointers + NEW_ALLOCATED_OFFSET, m->new_allocated);
|
|
111
|
-
SortPointers(m->pointers + NEW_FREED_OFFSET, m->new_freed);
|
|
112
|
-
annihilated = Annihilate(
|
|
113
|
-
m->pointers + NEW_ALLOCATED_OFFSET, m->new_allocated,
|
|
114
|
-
m->pointers + NEW_FREED_OFFSET, m->new_freed);
|
|
115
|
-
m->new_allocated -= annihilated;
|
|
116
|
-
m->new_freed -= annihilated;
|
|
117
|
-
|
|
118
|
-
if (m->new_freed != 0) {
|
|
119
|
-
annihilated = Annihilate(
|
|
120
|
-
m->pointers + PERM_ALLOCATED_OFFSET, m->perm_allocated,
|
|
121
|
-
m->pointers + NEW_FREED_OFFSET, m->new_freed);
|
|
122
|
-
m->perm_allocated -= annihilated;
|
|
123
|
-
m->new_freed -= annihilated;
|
|
124
|
-
BROTLI_DCHECK(m->new_freed == 0);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (m->new_allocated != 0) {
|
|
128
|
-
BROTLI_DCHECK(m->perm_allocated + m->new_allocated <= MAX_PERM_ALLOCATED);
|
|
129
|
-
memcpy(m->pointers + PERM_ALLOCATED_OFFSET + m->perm_allocated,
|
|
130
|
-
m->pointers + NEW_ALLOCATED_OFFSET,
|
|
131
|
-
sizeof(void*) * m->new_allocated);
|
|
132
|
-
m->perm_allocated += m->new_allocated;
|
|
133
|
-
m->new_allocated = 0;
|
|
134
|
-
SortPointers(m->pointers + PERM_ALLOCATED_OFFSET, m->perm_allocated);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
void* BrotliAllocate(MemoryManager* m, size_t n) {
|
|
139
|
-
void* result = m->alloc_func(m->opaque, n);
|
|
140
|
-
if (!result) {
|
|
141
|
-
m->is_oom = BROTLI_TRUE;
|
|
142
|
-
return NULL;
|
|
143
|
-
}
|
|
144
|
-
if (m->new_allocated == MAX_NEW_ALLOCATED) CollectGarbagePointers(m);
|
|
145
|
-
m->pointers[NEW_ALLOCATED_OFFSET + (m->new_allocated++)] = result;
|
|
146
|
-
return result;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
void BrotliFree(MemoryManager* m, void* p) {
|
|
150
|
-
if (!p) return;
|
|
151
|
-
m->free_func(m->opaque, p);
|
|
152
|
-
if (m->new_freed == MAX_NEW_FREED) CollectGarbagePointers(m);
|
|
153
|
-
m->pointers[NEW_FREED_OFFSET + (m->new_freed++)] = p;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
void BrotliWipeOutMemoryManager(MemoryManager* m) {
|
|
157
|
-
size_t i;
|
|
158
|
-
CollectGarbagePointers(m);
|
|
159
|
-
/* Now all unfreed pointers are in perm-allocated list. */
|
|
160
|
-
for (i = 0; i < m->perm_allocated; ++i) {
|
|
161
|
-
m->free_func(m->opaque, m->pointers[PERM_ALLOCATED_OFFSET + i]);
|
|
162
|
-
}
|
|
163
|
-
m->perm_allocated = 0;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
#endif /* BROTLI_ENCODER_EXIT_ON_OOM */
|
|
167
|
-
|
|
168
|
-
#if defined(__cplusplus) || defined(c_plusplus)
|
|
169
|
-
} /* extern "C" */
|
|
170
|
-
#endif
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
/* Copyright 2016 Google Inc. All Rights Reserved.
|
|
2
|
-
|
|
3
|
-
Distributed under MIT license.
|
|
4
|
-
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/* Macros for memory management. */
|
|
8
|
-
|
|
9
|
-
#ifndef BROTLI_ENC_MEMORY_H_
|
|
10
|
-
#define BROTLI_ENC_MEMORY_H_
|
|
11
|
-
|
|
12
|
-
#include <string.h> /* memcpy */
|
|
13
|
-
|
|
14
|
-
#include "../common/platform.h"
|
|
15
|
-
#include <brotli/types.h>
|
|
16
|
-
|
|
17
|
-
#if defined(__cplusplus) || defined(c_plusplus)
|
|
18
|
-
extern "C" {
|
|
19
|
-
#endif
|
|
20
|
-
|
|
21
|
-
#if !defined(BROTLI_ENCODER_CLEANUP_ON_OOM) && \
|
|
22
|
-
!defined(BROTLI_ENCODER_EXIT_ON_OOM)
|
|
23
|
-
#define BROTLI_ENCODER_EXIT_ON_OOM
|
|
24
|
-
#endif
|
|
25
|
-
|
|
26
|
-
typedef struct MemoryManager {
|
|
27
|
-
brotli_alloc_func alloc_func;
|
|
28
|
-
brotli_free_func free_func;
|
|
29
|
-
void* opaque;
|
|
30
|
-
#if !defined(BROTLI_ENCODER_EXIT_ON_OOM)
|
|
31
|
-
BROTLI_BOOL is_oom;
|
|
32
|
-
size_t perm_allocated;
|
|
33
|
-
size_t new_allocated;
|
|
34
|
-
size_t new_freed;
|
|
35
|
-
void* pointers[256];
|
|
36
|
-
#endif /* BROTLI_ENCODER_EXIT_ON_OOM */
|
|
37
|
-
} MemoryManager;
|
|
38
|
-
|
|
39
|
-
BROTLI_INTERNAL void BrotliInitMemoryManager(
|
|
40
|
-
MemoryManager* m, brotli_alloc_func alloc_func, brotli_free_func free_func,
|
|
41
|
-
void* opaque);
|
|
42
|
-
|
|
43
|
-
BROTLI_INTERNAL void* BrotliAllocate(MemoryManager* m, size_t n);
|
|
44
|
-
#define BROTLI_ALLOC(M, T, N) \
|
|
45
|
-
((N) > 0 ? ((T*)BrotliAllocate((M), (N) * sizeof(T))) : NULL)
|
|
46
|
-
|
|
47
|
-
BROTLI_INTERNAL void BrotliFree(MemoryManager* m, void* p);
|
|
48
|
-
#define BROTLI_FREE(M, P) { \
|
|
49
|
-
BrotliFree((M), (P)); \
|
|
50
|
-
P = NULL; \
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
#if defined(BROTLI_ENCODER_EXIT_ON_OOM)
|
|
54
|
-
#define BROTLI_IS_OOM(M) (!!0)
|
|
55
|
-
#else /* BROTLI_ENCODER_EXIT_ON_OOM */
|
|
56
|
-
#define BROTLI_IS_OOM(M) (!!(M)->is_oom)
|
|
57
|
-
#endif /* BROTLI_ENCODER_EXIT_ON_OOM */
|
|
58
|
-
|
|
59
|
-
/*
|
|
60
|
-
BROTLI_IS_NULL is a fake check, BROTLI_IS_OOM does the heavy lifting.
|
|
61
|
-
The only purpose of it is to explain static analyzers the state of things.
|
|
62
|
-
NB: use ONLY together with BROTLI_IS_OOM
|
|
63
|
-
AND ONLY for allocations in the current scope.
|
|
64
|
-
*/
|
|
65
|
-
#if defined(__clang_analyzer__) && !defined(BROTLI_ENCODER_EXIT_ON_OOM)
|
|
66
|
-
#define BROTLI_IS_NULL(A) ((A) == nullptr)
|
|
67
|
-
#else /* defined(__clang_analyzer__) */
|
|
68
|
-
#define BROTLI_IS_NULL(A) (!!0)
|
|
69
|
-
#endif /* defined(__clang_analyzer__) */
|
|
70
|
-
|
|
71
|
-
BROTLI_INTERNAL void BrotliWipeOutMemoryManager(MemoryManager* m);
|
|
72
|
-
|
|
73
|
-
/*
|
|
74
|
-
Dynamically grows array capacity to at least the requested size
|
|
75
|
-
M: MemoryManager
|
|
76
|
-
T: data type
|
|
77
|
-
A: array
|
|
78
|
-
C: capacity
|
|
79
|
-
R: requested size
|
|
80
|
-
*/
|
|
81
|
-
#define BROTLI_ENSURE_CAPACITY(M, T, A, C, R) { \
|
|
82
|
-
if (C < (R)) { \
|
|
83
|
-
size_t _new_size = (C == 0) ? (R) : C; \
|
|
84
|
-
T* new_array; \
|
|
85
|
-
while (_new_size < (R)) _new_size *= 2; \
|
|
86
|
-
new_array = BROTLI_ALLOC((M), T, _new_size); \
|
|
87
|
-
if (!BROTLI_IS_OOM(M) && !BROTLI_IS_NULL(new_array) && C != 0) \
|
|
88
|
-
memcpy(new_array, A, C * sizeof(T)); \
|
|
89
|
-
BROTLI_FREE((M), A); \
|
|
90
|
-
A = new_array; \
|
|
91
|
-
C = _new_size; \
|
|
92
|
-
} \
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/*
|
|
96
|
-
Appends value and dynamically grows array capacity when needed
|
|
97
|
-
M: MemoryManager
|
|
98
|
-
T: data type
|
|
99
|
-
A: array
|
|
100
|
-
C: array capacity
|
|
101
|
-
S: array size
|
|
102
|
-
V: value to append
|
|
103
|
-
*/
|
|
104
|
-
#define BROTLI_ENSURE_CAPACITY_APPEND(M, T, A, C, S, V) { \
|
|
105
|
-
(S)++; \
|
|
106
|
-
BROTLI_ENSURE_CAPACITY(M, T, A, C, S); \
|
|
107
|
-
A[(S) - 1] = (V); \
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
#if defined(__cplusplus) || defined(c_plusplus)
|
|
111
|
-
} /* extern "C" */
|
|
112
|
-
#endif
|
|
113
|
-
|
|
114
|
-
#endif /* BROTLI_ENC_MEMORY_H_ */
|