zstdlib 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGES.md +9 -0
  3. data/Gemfile +3 -0
  4. data/README.md +96 -0
  5. data/Rakefile +29 -0
  6. data/ext/zstdlib/extconf.rb +53 -0
  7. data/ext/zstdlib/ruby/zlib-2.2/zlib.c +4659 -0
  8. data/ext/zstdlib/ruby/zlib-2.3/zlib.c +4686 -0
  9. data/ext/zstdlib/ruby/zlib-2.4/zlib.c +4843 -0
  10. data/ext/zstdlib/ruby/zlib-2.5/zlib.c +4848 -0
  11. data/ext/zstdlib/ruby/zlib-2.6/zlib.c +4890 -0
  12. data/ext/zstdlib/zlib-1.2.11/adler32.c +186 -0
  13. data/ext/zstdlib/zlib-1.2.11/compress.c +86 -0
  14. data/ext/zstdlib/zlib-1.2.11/crc32.c +442 -0
  15. data/ext/zstdlib/zlib-1.2.11/crc32.h +441 -0
  16. data/ext/zstdlib/zlib-1.2.11/deflate.c +2163 -0
  17. data/ext/zstdlib/zlib-1.2.11/deflate.h +349 -0
  18. data/ext/zstdlib/zlib-1.2.11/gzclose.c +25 -0
  19. data/ext/zstdlib/zlib-1.2.11/gzguts.h +218 -0
  20. data/ext/zstdlib/zlib-1.2.11/gzlib.c +637 -0
  21. data/ext/zstdlib/zlib-1.2.11/gzread.c +654 -0
  22. data/ext/zstdlib/zlib-1.2.11/gzwrite.c +665 -0
  23. data/ext/zstdlib/zlib-1.2.11/infback.c +640 -0
  24. data/ext/zstdlib/zlib-1.2.11/inffast.c +323 -0
  25. data/ext/zstdlib/zlib-1.2.11/inffast.h +11 -0
  26. data/ext/zstdlib/zlib-1.2.11/inffixed.h +94 -0
  27. data/ext/zstdlib/zlib-1.2.11/inflate.c +1561 -0
  28. data/ext/zstdlib/zlib-1.2.11/inflate.h +125 -0
  29. data/ext/zstdlib/zlib-1.2.11/inftrees.c +304 -0
  30. data/ext/zstdlib/zlib-1.2.11/inftrees.h +62 -0
  31. data/ext/zstdlib/zlib-1.2.11/trees.c +1203 -0
  32. data/ext/zstdlib/zlib-1.2.11/trees.h +128 -0
  33. data/ext/zstdlib/zlib-1.2.11/uncompr.c +93 -0
  34. data/ext/zstdlib/zlib-1.2.11/zconf.h +534 -0
  35. data/ext/zstdlib/zlib-1.2.11/zlib.h +1912 -0
  36. data/ext/zstdlib/zlib-1.2.11/zutil.c +325 -0
  37. data/ext/zstdlib/zlib-1.2.11/zutil.h +271 -0
  38. data/ext/zstdlib/zlib.mk +14 -0
  39. data/ext/zstdlib/zlibwrapper/zlibwrapper.c +14 -0
  40. data/ext/zstdlib/zlibwrapper.mk +14 -0
  41. data/ext/zstdlib/zstd-1.3.8/lib/common/bitstream.h +455 -0
  42. data/ext/zstdlib/zstd-1.3.8/lib/common/compiler.h +140 -0
  43. data/ext/zstdlib/zstd-1.3.8/lib/common/cpu.h +215 -0
  44. data/ext/zstdlib/zstd-1.3.8/lib/common/debug.c +44 -0
  45. data/ext/zstdlib/zstd-1.3.8/lib/common/debug.h +134 -0
  46. data/ext/zstdlib/zstd-1.3.8/lib/common/entropy_common.c +236 -0
  47. data/ext/zstdlib/zstd-1.3.8/lib/common/error_private.c +54 -0
  48. data/ext/zstdlib/zstd-1.3.8/lib/common/error_private.h +76 -0
  49. data/ext/zstdlib/zstd-1.3.8/lib/common/fse.h +708 -0
  50. data/ext/zstdlib/zstd-1.3.8/lib/common/fse_decompress.c +309 -0
  51. data/ext/zstdlib/zstd-1.3.8/lib/common/huf.h +358 -0
  52. data/ext/zstdlib/zstd-1.3.8/lib/common/mem.h +380 -0
  53. data/ext/zstdlib/zstd-1.3.8/lib/common/pool.c +340 -0
  54. data/ext/zstdlib/zstd-1.3.8/lib/common/pool.h +84 -0
  55. data/ext/zstdlib/zstd-1.3.8/lib/common/threading.c +75 -0
  56. data/ext/zstdlib/zstd-1.3.8/lib/common/threading.h +123 -0
  57. data/ext/zstdlib/zstd-1.3.8/lib/common/xxhash.c +876 -0
  58. data/ext/zstdlib/zstd-1.3.8/lib/common/xxhash.h +305 -0
  59. data/ext/zstdlib/zstd-1.3.8/lib/common/zstd_common.c +83 -0
  60. data/ext/zstdlib/zstd-1.3.8/lib/common/zstd_errors.h +93 -0
  61. data/ext/zstdlib/zstd-1.3.8/lib/common/zstd_internal.h +266 -0
  62. data/ext/zstdlib/zstd-1.3.8/lib/compress/fse_compress.c +721 -0
  63. data/ext/zstdlib/zstd-1.3.8/lib/compress/hist.c +203 -0
  64. data/ext/zstdlib/zstd-1.3.8/lib/compress/hist.h +95 -0
  65. data/ext/zstdlib/zstd-1.3.8/lib/compress/huf_compress.c +798 -0
  66. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_compress.c +4290 -0
  67. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_compress_internal.h +860 -0
  68. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_double_fast.c +499 -0
  69. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_double_fast.h +38 -0
  70. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_fast.c +391 -0
  71. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_fast.h +37 -0
  72. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_lazy.c +1106 -0
  73. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_lazy.h +67 -0
  74. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_ldm.c +597 -0
  75. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_ldm.h +105 -0
  76. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_opt.c +1217 -0
  77. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstd_opt.h +56 -0
  78. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstdmt_compress.c +2107 -0
  79. data/ext/zstdlib/zstd-1.3.8/lib/compress/zstdmt_compress.h +174 -0
  80. data/ext/zstdlib/zstd-1.3.8/lib/decompress/huf_decompress.c +1232 -0
  81. data/ext/zstdlib/zstd-1.3.8/lib/decompress/zstd_ddict.c +240 -0
  82. data/ext/zstdlib/zstd-1.3.8/lib/decompress/zstd_ddict.h +44 -0
  83. data/ext/zstdlib/zstd-1.3.8/lib/decompress/zstd_decompress.c +1672 -0
  84. data/ext/zstdlib/zstd-1.3.8/lib/decompress/zstd_decompress_block.c +1307 -0
  85. data/ext/zstdlib/zstd-1.3.8/lib/decompress/zstd_decompress_block.h +59 -0
  86. data/ext/zstdlib/zstd-1.3.8/lib/decompress/zstd_decompress_internal.h +168 -0
  87. data/ext/zstdlib/zstd-1.3.8/lib/zstd.h +1766 -0
  88. data/ext/zstdlib/zstd-1.3.8/zlibWrapper/gzclose.c +28 -0
  89. data/ext/zstdlib/zstd-1.3.8/zlibWrapper/gzcompatibility.h +68 -0
  90. data/ext/zstdlib/zstd-1.3.8/zlibWrapper/gzguts.h +227 -0
  91. data/ext/zstdlib/zstd-1.3.8/zlibWrapper/gzlib.c +640 -0
  92. data/ext/zstdlib/zstd-1.3.8/zlibWrapper/gzread.c +670 -0
  93. data/ext/zstdlib/zstd-1.3.8/zlibWrapper/gzwrite.c +671 -0
  94. data/ext/zstdlib/zstd-1.3.8/zlibWrapper/zstd_zlibwrapper.c +1105 -0
  95. data/ext/zstdlib/zstd-1.3.8/zlibWrapper/zstd_zlibwrapper.h +88 -0
  96. data/ext/zstdlib/zstd.mk +14 -0
  97. data/lib/zstdlib.rb +6 -0
  98. data/test/zstdlib_test.rb +21 -0
  99. metadata +198 -0
@@ -0,0 +1,203 @@
1
+ /* ******************************************************************
2
+ hist : Histogram functions
3
+ part of Finite State Entropy project
4
+ Copyright (C) 2013-present, Yann Collet.
5
+
6
+ BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
7
+
8
+ Redistribution and use in source and binary forms, with or without
9
+ modification, are permitted provided that the following conditions are
10
+ met:
11
+
12
+ * Redistributions of source code must retain the above copyright
13
+ notice, this list of conditions and the following disclaimer.
14
+ * Redistributions in binary form must reproduce the above
15
+ copyright notice, this list of conditions and the following disclaimer
16
+ in the documentation and/or other materials provided with the
17
+ distribution.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
+
31
+ You can contact the author at :
32
+ - FSE source repository : https://github.com/Cyan4973/FiniteStateEntropy
33
+ - Public forum : https://groups.google.com/forum/#!forum/lz4c
34
+ ****************************************************************** */
35
+
36
+ /* --- dependencies --- */
37
+ #include "mem.h" /* U32, BYTE, etc. */
38
+ #include "debug.h" /* assert, DEBUGLOG */
39
+ #include "error_private.h" /* ERROR */
40
+ #include "hist.h"
41
+
42
+
43
+ /* --- Error management --- */
44
+ unsigned HIST_isError(size_t code) { return ERR_isError(code); }
45
+
46
+ /*-**************************************************************
47
+ * Histogram functions
48
+ ****************************************************************/
49
+ unsigned HIST_count_simple(unsigned* count, unsigned* maxSymbolValuePtr,
50
+ const void* src, size_t srcSize)
51
+ {
52
+ const BYTE* ip = (const BYTE*)src;
53
+ const BYTE* const end = ip + srcSize;
54
+ unsigned maxSymbolValue = *maxSymbolValuePtr;
55
+ unsigned largestCount=0;
56
+
57
+ memset(count, 0, (maxSymbolValue+1) * sizeof(*count));
58
+ if (srcSize==0) { *maxSymbolValuePtr = 0; return 0; }
59
+
60
+ while (ip<end) {
61
+ assert(*ip <= maxSymbolValue);
62
+ count[*ip++]++;
63
+ }
64
+
65
+ while (!count[maxSymbolValue]) maxSymbolValue--;
66
+ *maxSymbolValuePtr = maxSymbolValue;
67
+
68
+ { U32 s;
69
+ for (s=0; s<=maxSymbolValue; s++)
70
+ if (count[s] > largestCount) largestCount = count[s];
71
+ }
72
+
73
+ return largestCount;
74
+ }
75
+
76
+ typedef enum { trustInput, checkMaxSymbolValue } HIST_checkInput_e;
77
+
78
+ /* HIST_count_parallel_wksp() :
79
+ * store histogram into 4 intermediate tables, recombined at the end.
80
+ * this design makes better use of OoO cpus,
81
+ * and is noticeably faster when some values are heavily repeated.
82
+ * But it needs some additional workspace for intermediate tables.
83
+ * `workSpace` size must be a table of size >= HIST_WKSP_SIZE_U32.
84
+ * @return : largest histogram frequency,
85
+ * or an error code (notably when histogram would be larger than *maxSymbolValuePtr). */
86
+ static size_t HIST_count_parallel_wksp(
87
+ unsigned* count, unsigned* maxSymbolValuePtr,
88
+ const void* source, size_t sourceSize,
89
+ HIST_checkInput_e check,
90
+ U32* const workSpace)
91
+ {
92
+ const BYTE* ip = (const BYTE*)source;
93
+ const BYTE* const iend = ip+sourceSize;
94
+ unsigned maxSymbolValue = *maxSymbolValuePtr;
95
+ unsigned max=0;
96
+ U32* const Counting1 = workSpace;
97
+ U32* const Counting2 = Counting1 + 256;
98
+ U32* const Counting3 = Counting2 + 256;
99
+ U32* const Counting4 = Counting3 + 256;
100
+
101
+ memset(workSpace, 0, 4*256*sizeof(unsigned));
102
+
103
+ /* safety checks */
104
+ if (!sourceSize) {
105
+ memset(count, 0, maxSymbolValue + 1);
106
+ *maxSymbolValuePtr = 0;
107
+ return 0;
108
+ }
109
+ if (!maxSymbolValue) maxSymbolValue = 255; /* 0 == default */
110
+
111
+ /* by stripes of 16 bytes */
112
+ { U32 cached = MEM_read32(ip); ip += 4;
113
+ while (ip < iend-15) {
114
+ U32 c = cached; cached = MEM_read32(ip); ip += 4;
115
+ Counting1[(BYTE) c ]++;
116
+ Counting2[(BYTE)(c>>8) ]++;
117
+ Counting3[(BYTE)(c>>16)]++;
118
+ Counting4[ c>>24 ]++;
119
+ c = cached; cached = MEM_read32(ip); ip += 4;
120
+ Counting1[(BYTE) c ]++;
121
+ Counting2[(BYTE)(c>>8) ]++;
122
+ Counting3[(BYTE)(c>>16)]++;
123
+ Counting4[ c>>24 ]++;
124
+ c = cached; cached = MEM_read32(ip); ip += 4;
125
+ Counting1[(BYTE) c ]++;
126
+ Counting2[(BYTE)(c>>8) ]++;
127
+ Counting3[(BYTE)(c>>16)]++;
128
+ Counting4[ c>>24 ]++;
129
+ c = cached; cached = MEM_read32(ip); ip += 4;
130
+ Counting1[(BYTE) c ]++;
131
+ Counting2[(BYTE)(c>>8) ]++;
132
+ Counting3[(BYTE)(c>>16)]++;
133
+ Counting4[ c>>24 ]++;
134
+ }
135
+ ip-=4;
136
+ }
137
+
138
+ /* finish last symbols */
139
+ while (ip<iend) Counting1[*ip++]++;
140
+
141
+ if (check) { /* verify stats will fit into destination table */
142
+ U32 s; for (s=255; s>maxSymbolValue; s--) {
143
+ Counting1[s] += Counting2[s] + Counting3[s] + Counting4[s];
144
+ if (Counting1[s]) return ERROR(maxSymbolValue_tooSmall);
145
+ } }
146
+
147
+ { U32 s;
148
+ if (maxSymbolValue > 255) maxSymbolValue = 255;
149
+ for (s=0; s<=maxSymbolValue; s++) {
150
+ count[s] = Counting1[s] + Counting2[s] + Counting3[s] + Counting4[s];
151
+ if (count[s] > max) max = count[s];
152
+ } }
153
+
154
+ while (!count[maxSymbolValue]) maxSymbolValue--;
155
+ *maxSymbolValuePtr = maxSymbolValue;
156
+ return (size_t)max;
157
+ }
158
+
159
+ /* HIST_countFast_wksp() :
160
+ * Same as HIST_countFast(), but using an externally provided scratch buffer.
161
+ * `workSpace` is a writable buffer which must be 4-bytes aligned,
162
+ * `workSpaceSize` must be >= HIST_WKSP_SIZE
163
+ */
164
+ size_t HIST_countFast_wksp(unsigned* count, unsigned* maxSymbolValuePtr,
165
+ const void* source, size_t sourceSize,
166
+ void* workSpace, size_t workSpaceSize)
167
+ {
168
+ if (sourceSize < 1500) /* heuristic threshold */
169
+ return HIST_count_simple(count, maxSymbolValuePtr, source, sourceSize);
170
+ if ((size_t)workSpace & 3) return ERROR(GENERIC); /* must be aligned on 4-bytes boundaries */
171
+ if (workSpaceSize < HIST_WKSP_SIZE) return ERROR(workSpace_tooSmall);
172
+ return HIST_count_parallel_wksp(count, maxSymbolValuePtr, source, sourceSize, trustInput, (U32*)workSpace);
173
+ }
174
+
175
+ /* fast variant (unsafe : won't check if src contains values beyond count[] limit) */
176
+ size_t HIST_countFast(unsigned* count, unsigned* maxSymbolValuePtr,
177
+ const void* source, size_t sourceSize)
178
+ {
179
+ unsigned tmpCounters[HIST_WKSP_SIZE_U32];
180
+ return HIST_countFast_wksp(count, maxSymbolValuePtr, source, sourceSize, tmpCounters, sizeof(tmpCounters));
181
+ }
182
+
183
+ /* HIST_count_wksp() :
184
+ * Same as HIST_count(), but using an externally provided scratch buffer.
185
+ * `workSpace` size must be table of >= HIST_WKSP_SIZE_U32 unsigned */
186
+ size_t HIST_count_wksp(unsigned* count, unsigned* maxSymbolValuePtr,
187
+ const void* source, size_t sourceSize,
188
+ void* workSpace, size_t workSpaceSize)
189
+ {
190
+ if ((size_t)workSpace & 3) return ERROR(GENERIC); /* must be aligned on 4-bytes boundaries */
191
+ if (workSpaceSize < HIST_WKSP_SIZE) return ERROR(workSpace_tooSmall);
192
+ if (*maxSymbolValuePtr < 255)
193
+ return HIST_count_parallel_wksp(count, maxSymbolValuePtr, source, sourceSize, checkMaxSymbolValue, (U32*)workSpace);
194
+ *maxSymbolValuePtr = 255;
195
+ return HIST_countFast_wksp(count, maxSymbolValuePtr, source, sourceSize, workSpace, workSpaceSize);
196
+ }
197
+
198
+ size_t HIST_count(unsigned* count, unsigned* maxSymbolValuePtr,
199
+ const void* src, size_t srcSize)
200
+ {
201
+ unsigned tmpCounters[HIST_WKSP_SIZE_U32];
202
+ return HIST_count_wksp(count, maxSymbolValuePtr, src, srcSize, tmpCounters, sizeof(tmpCounters));
203
+ }
@@ -0,0 +1,95 @@
1
+ /* ******************************************************************
2
+ hist : Histogram functions
3
+ part of Finite State Entropy project
4
+ Copyright (C) 2013-present, Yann Collet.
5
+
6
+ BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
7
+
8
+ Redistribution and use in source and binary forms, with or without
9
+ modification, are permitted provided that the following conditions are
10
+ met:
11
+
12
+ * Redistributions of source code must retain the above copyright
13
+ notice, this list of conditions and the following disclaimer.
14
+ * Redistributions in binary form must reproduce the above
15
+ copyright notice, this list of conditions and the following disclaimer
16
+ in the documentation and/or other materials provided with the
17
+ distribution.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
+
31
+ You can contact the author at :
32
+ - FSE source repository : https://github.com/Cyan4973/FiniteStateEntropy
33
+ - Public forum : https://groups.google.com/forum/#!forum/lz4c
34
+ ****************************************************************** */
35
+
36
+ /* --- dependencies --- */
37
+ #include <stddef.h> /* size_t */
38
+
39
+
40
+ /* --- simple histogram functions --- */
41
+
42
+ /*! HIST_count():
43
+ * Provides the precise count of each byte within a table 'count'.
44
+ * 'count' is a table of unsigned int, of minimum size (*maxSymbolValuePtr+1).
45
+ * Updates *maxSymbolValuePtr with actual largest symbol value detected.
46
+ * @return : count of the most frequent symbol (which isn't identified).
47
+ * or an error code, which can be tested using HIST_isError().
48
+ * note : if return == srcSize, there is only one symbol.
49
+ */
50
+ size_t HIST_count(unsigned* count, unsigned* maxSymbolValuePtr,
51
+ const void* src, size_t srcSize);
52
+
53
+ unsigned HIST_isError(size_t code); /**< tells if a return value is an error code */
54
+
55
+
56
+ /* --- advanced histogram functions --- */
57
+
58
+ #define HIST_WKSP_SIZE_U32 1024
59
+ #define HIST_WKSP_SIZE (HIST_WKSP_SIZE_U32 * sizeof(unsigned))
60
+ /** HIST_count_wksp() :
61
+ * Same as HIST_count(), but using an externally provided scratch buffer.
62
+ * Benefit is this function will use very little stack space.
63
+ * `workSpace` is a writable buffer which must be 4-bytes aligned,
64
+ * `workSpaceSize` must be >= HIST_WKSP_SIZE
65
+ */
66
+ size_t HIST_count_wksp(unsigned* count, unsigned* maxSymbolValuePtr,
67
+ const void* src, size_t srcSize,
68
+ void* workSpace, size_t workSpaceSize);
69
+
70
+ /** HIST_countFast() :
71
+ * same as HIST_count(), but blindly trusts that all byte values within src are <= *maxSymbolValuePtr.
72
+ * This function is unsafe, and will segfault if any value within `src` is `> *maxSymbolValuePtr`
73
+ */
74
+ size_t HIST_countFast(unsigned* count, unsigned* maxSymbolValuePtr,
75
+ const void* src, size_t srcSize);
76
+
77
+ /** HIST_countFast_wksp() :
78
+ * Same as HIST_countFast(), but using an externally provided scratch buffer.
79
+ * `workSpace` is a writable buffer which must be 4-bytes aligned,
80
+ * `workSpaceSize` must be >= HIST_WKSP_SIZE
81
+ */
82
+ size_t HIST_countFast_wksp(unsigned* count, unsigned* maxSymbolValuePtr,
83
+ const void* src, size_t srcSize,
84
+ void* workSpace, size_t workSpaceSize);
85
+
86
+ /*! HIST_count_simple() :
87
+ * Same as HIST_countFast(), this function is unsafe,
88
+ * and will segfault if any value within `src` is `> *maxSymbolValuePtr`.
89
+ * It is also a bit slower for large inputs.
90
+ * However, it does not need any additional memory (not even on stack).
91
+ * @return : count of the most frequent symbol.
92
+ * Note this function doesn't produce any error (i.e. it must succeed).
93
+ */
94
+ unsigned HIST_count_simple(unsigned* count, unsigned* maxSymbolValuePtr,
95
+ const void* src, size_t srcSize);