zstdlib 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +9 -0
- data/ext/zstdlib_c/extconf.rb +8 -3
- data/ext/zstdlib_c/ruby/zlib-3.3/zstdlib.c +5090 -0
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/adler32.c +5 -27
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/compress.c +5 -16
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/crc32.c +94 -161
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/deflate.c +362 -434
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/deflate.h +43 -12
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/gzclose.c +1 -3
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/gzguts.h +13 -18
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/gzlib.c +28 -85
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/gzread.c +23 -73
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/gzwrite.c +19 -65
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/infback.c +17 -30
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/inffast.c +1 -4
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/inffast.h +1 -1
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/inflate.c +36 -102
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/inftrees.c +6 -11
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/inftrees.h +6 -6
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/trees.c +290 -355
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/uncompr.c +4 -12
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/zconf.h +23 -14
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/zlib.h +202 -199
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/zutil.c +18 -44
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/zutil.h +13 -33
- metadata +33 -32
- /data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/crc32.h +0 -0
- /data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/inffixed.h +0 -0
- /data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/inflate.h +0 -0
- /data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/trees.h +0 -0
@@ -5,18 +5,10 @@
|
|
5
5
|
|
6
6
|
#include "gzguts.h"
|
7
7
|
|
8
|
-
/* Local functions */
|
9
|
-
local int gz_init OF((gz_statep));
|
10
|
-
local int gz_comp OF((gz_statep, int));
|
11
|
-
local int gz_zero OF((gz_statep, z_off64_t));
|
12
|
-
local z_size_t gz_write OF((gz_statep, voidpc, z_size_t));
|
13
|
-
|
14
8
|
/* Initialize state for writing a gzip file. Mark initialization by setting
|
15
9
|
state->size to non-zero. Return -1 on a memory allocation failure, or 0 on
|
16
10
|
success. */
|
17
|
-
local int gz_init(state)
|
18
|
-
gz_statep state;
|
19
|
-
{
|
11
|
+
local int gz_init(gz_statep state) {
|
20
12
|
int ret;
|
21
13
|
z_streamp strm = &(state->strm);
|
22
14
|
|
@@ -70,10 +62,7 @@ local int gz_init(state)
|
|
70
62
|
deflate() flush value. If flush is Z_FINISH, then the deflate() state is
|
71
63
|
reset to start a new gzip stream. If gz->direct is true, then simply write
|
72
64
|
to the output file without compressing, and ignore flush. */
|
73
|
-
local int gz_comp(state, flush)
|
74
|
-
gz_statep state;
|
75
|
-
int flush;
|
76
|
-
{
|
65
|
+
local int gz_comp(gz_statep state, int flush) {
|
77
66
|
int ret, writ;
|
78
67
|
unsigned have, put, max = ((unsigned)-1 >> 2) + 1;
|
79
68
|
z_streamp strm = &(state->strm);
|
@@ -151,10 +140,7 @@ local int gz_comp(state, flush)
|
|
151
140
|
|
152
141
|
/* Compress len zeros to output. Return -1 on a write error or memory
|
153
142
|
allocation failure by gz_comp(), or 0 on success. */
|
154
|
-
local int gz_zero(state, len)
|
155
|
-
gz_statep state;
|
156
|
-
z_off64_t len;
|
157
|
-
{
|
143
|
+
local int gz_zero(gz_statep state, z_off64_t len) {
|
158
144
|
int first;
|
159
145
|
unsigned n;
|
160
146
|
z_streamp strm = &(state->strm);
|
@@ -184,11 +170,7 @@ local int gz_zero(state, len)
|
|
184
170
|
|
185
171
|
/* Write len bytes from buf to file. Return the number of bytes written. If
|
186
172
|
the returned value is less than len, then there was an error. */
|
187
|
-
local z_size_t gz_write(state, buf, len)
|
188
|
-
gz_statep state;
|
189
|
-
voidpc buf;
|
190
|
-
z_size_t len;
|
191
|
-
{
|
173
|
+
local z_size_t gz_write(gz_statep state, voidpc buf, z_size_t len) {
|
192
174
|
z_size_t put = len;
|
193
175
|
|
194
176
|
/* if len is zero, avoid unnecessary operations */
|
@@ -252,11 +234,7 @@ local z_size_t gz_write(state, buf, len)
|
|
252
234
|
}
|
253
235
|
|
254
236
|
/* -- see zlib.h -- */
|
255
|
-
int ZEXPORT gzwrite(file, buf, len)
|
256
|
-
gzFile file;
|
257
|
-
voidpc buf;
|
258
|
-
unsigned len;
|
259
|
-
{
|
237
|
+
int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len) {
|
260
238
|
gz_statep state;
|
261
239
|
|
262
240
|
/* get internal structure */
|
@@ -280,12 +258,8 @@ int ZEXPORT gzwrite(file, buf, len)
|
|
280
258
|
}
|
281
259
|
|
282
260
|
/* -- see zlib.h -- */
|
283
|
-
z_size_t ZEXPORT gzfwrite(buf, size, nitems,
|
284
|
-
|
285
|
-
z_size_t size;
|
286
|
-
z_size_t nitems;
|
287
|
-
gzFile file;
|
288
|
-
{
|
261
|
+
z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size, z_size_t nitems,
|
262
|
+
gzFile file) {
|
289
263
|
z_size_t len;
|
290
264
|
gz_statep state;
|
291
265
|
|
@@ -310,10 +284,7 @@ z_size_t ZEXPORT gzfwrite(buf, size, nitems, file)
|
|
310
284
|
}
|
311
285
|
|
312
286
|
/* -- see zlib.h -- */
|
313
|
-
int ZEXPORT gzputc(file, c)
|
314
|
-
gzFile file;
|
315
|
-
int c;
|
316
|
-
{
|
287
|
+
int ZEXPORT gzputc(gzFile file, int c) {
|
317
288
|
unsigned have;
|
318
289
|
unsigned char buf[1];
|
319
290
|
gz_statep state;
|
@@ -358,10 +329,7 @@ int ZEXPORT gzputc(file, c)
|
|
358
329
|
}
|
359
330
|
|
360
331
|
/* -- see zlib.h -- */
|
361
|
-
int ZEXPORT gzputs(file, s)
|
362
|
-
gzFile file;
|
363
|
-
const char *s;
|
364
|
-
{
|
332
|
+
int ZEXPORT gzputs(gzFile file, const char *s) {
|
365
333
|
z_size_t len, put;
|
366
334
|
gz_statep state;
|
367
335
|
|
@@ -388,8 +356,7 @@ int ZEXPORT gzputs(file, s)
|
|
388
356
|
#include <stdarg.h>
|
389
357
|
|
390
358
|
/* -- see zlib.h -- */
|
391
|
-
int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va)
|
392
|
-
{
|
359
|
+
int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) {
|
393
360
|
int len;
|
394
361
|
unsigned left;
|
395
362
|
char *next;
|
@@ -460,8 +427,7 @@ int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va)
|
|
460
427
|
return len;
|
461
428
|
}
|
462
429
|
|
463
|
-
int ZEXPORTVA gzprintf(gzFile file, const char *format, ...)
|
464
|
-
{
|
430
|
+
int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) {
|
465
431
|
va_list va;
|
466
432
|
int ret;
|
467
433
|
|
@@ -474,13 +440,10 @@ int ZEXPORTVA gzprintf(gzFile file, const char *format, ...)
|
|
474
440
|
#else /* !STDC && !Z_HAVE_STDARG_H */
|
475
441
|
|
476
442
|
/* -- see zlib.h -- */
|
477
|
-
int ZEXPORTVA gzprintf
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
|
482
|
-
a11, a12, a13, a14, a15, a16, a17, a18, a19, a20;
|
483
|
-
{
|
443
|
+
int ZEXPORTVA gzprintf(gzFile file, const char *format, int a1, int a2, int a3,
|
444
|
+
int a4, int a5, int a6, int a7, int a8, int a9, int a10,
|
445
|
+
int a11, int a12, int a13, int a14, int a15, int a16,
|
446
|
+
int a17, int a18, int a19, int a20) {
|
484
447
|
unsigned len, left;
|
485
448
|
char *next;
|
486
449
|
gz_statep state;
|
@@ -562,10 +525,7 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
|
|
562
525
|
#endif
|
563
526
|
|
564
527
|
/* -- see zlib.h -- */
|
565
|
-
int ZEXPORT gzflush(file, flush)
|
566
|
-
gzFile file;
|
567
|
-
int flush;
|
568
|
-
{
|
528
|
+
int ZEXPORT gzflush(gzFile file, int flush) {
|
569
529
|
gz_statep state;
|
570
530
|
|
571
531
|
/* get internal structure */
|
@@ -594,11 +554,7 @@ int ZEXPORT gzflush(file, flush)
|
|
594
554
|
}
|
595
555
|
|
596
556
|
/* -- see zlib.h -- */
|
597
|
-
int ZEXPORT gzsetparams(file, level, strategy)
|
598
|
-
gzFile file;
|
599
|
-
int level;
|
600
|
-
int strategy;
|
601
|
-
{
|
557
|
+
int ZEXPORT gzsetparams(gzFile file, int level, int strategy) {
|
602
558
|
gz_statep state;
|
603
559
|
z_streamp strm;
|
604
560
|
|
@@ -609,7 +565,7 @@ int ZEXPORT gzsetparams(file, level, strategy)
|
|
609
565
|
strm = &(state->strm);
|
610
566
|
|
611
567
|
/* check that we're writing and that there's no error */
|
612
|
-
if (state->mode != GZ_WRITE || state->err != Z_OK)
|
568
|
+
if (state->mode != GZ_WRITE || state->err != Z_OK || state->direct)
|
613
569
|
return Z_STREAM_ERROR;
|
614
570
|
|
615
571
|
/* if no change is requested, then do nothing */
|
@@ -636,9 +592,7 @@ int ZEXPORT gzsetparams(file, level, strategy)
|
|
636
592
|
}
|
637
593
|
|
638
594
|
/* -- see zlib.h -- */
|
639
|
-
int ZEXPORT gzclose_w(file)
|
640
|
-
gzFile file;
|
641
|
-
{
|
595
|
+
int ZEXPORT gzclose_w(gzFile file) {
|
642
596
|
int ret = Z_OK;
|
643
597
|
gz_statep state;
|
644
598
|
|
@@ -15,9 +15,6 @@
|
|
15
15
|
#include "inflate.h"
|
16
16
|
#include "inffast.h"
|
17
17
|
|
18
|
-
/* function prototypes */
|
19
|
-
local void fixedtables OF((struct inflate_state FAR *state));
|
20
|
-
|
21
18
|
/*
|
22
19
|
strm provides memory allocation functions in zalloc and zfree, or
|
23
20
|
Z_NULL to use the library memory allocation functions.
|
@@ -25,13 +22,9 @@ local void fixedtables OF((struct inflate_state FAR *state));
|
|
25
22
|
windowBits is in the range 8..15, and window is a user-supplied
|
26
23
|
window and output buffer that is 2**windowBits bytes.
|
27
24
|
*/
|
28
|
-
int ZEXPORT inflateBackInit_(strm, windowBits,
|
29
|
-
|
30
|
-
int
|
31
|
-
unsigned char FAR *window;
|
32
|
-
const char *version;
|
33
|
-
int stream_size;
|
34
|
-
{
|
25
|
+
int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits,
|
26
|
+
unsigned char FAR *window, const char *version,
|
27
|
+
int stream_size) {
|
35
28
|
struct inflate_state FAR *state;
|
36
29
|
|
37
30
|
if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
|
@@ -66,6 +59,7 @@ int stream_size;
|
|
66
59
|
state->window = window;
|
67
60
|
state->wnext = 0;
|
68
61
|
state->whave = 0;
|
62
|
+
state->sane = 1;
|
69
63
|
return Z_OK;
|
70
64
|
}
|
71
65
|
|
@@ -79,9 +73,7 @@ int stream_size;
|
|
79
73
|
used for threaded applications, since the rewriting of the tables and virgin
|
80
74
|
may not be thread-safe.
|
81
75
|
*/
|
82
|
-
local void fixedtables(state)
|
83
|
-
struct inflate_state FAR *state;
|
84
|
-
{
|
76
|
+
local void fixedtables(struct inflate_state FAR *state) {
|
85
77
|
#ifdef BUILDFIXED
|
86
78
|
static int virgin = 1;
|
87
79
|
static code *lenfix, *distfix;
|
@@ -247,13 +239,8 @@ struct inflate_state FAR *state;
|
|
247
239
|
inflateBack() can also return Z_STREAM_ERROR if the input parameters
|
248
240
|
are not correct, i.e. strm is Z_NULL or the state was not initialized.
|
249
241
|
*/
|
250
|
-
int ZEXPORT inflateBack(strm, in, in_desc,
|
251
|
-
|
252
|
-
in_func in;
|
253
|
-
void FAR *in_desc;
|
254
|
-
out_func out;
|
255
|
-
void FAR *out_desc;
|
256
|
-
{
|
242
|
+
int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
|
243
|
+
out_func out, void FAR *out_desc) {
|
257
244
|
struct inflate_state FAR *state;
|
258
245
|
z_const unsigned char FAR *next; /* next input */
|
259
246
|
unsigned char FAR *put; /* next output */
|
@@ -605,33 +592,33 @@ void FAR *out_desc;
|
|
605
592
|
break;
|
606
593
|
|
607
594
|
case DONE:
|
608
|
-
/* inflate stream terminated properly
|
595
|
+
/* inflate stream terminated properly */
|
609
596
|
ret = Z_STREAM_END;
|
610
|
-
if (left < state->wsize) {
|
611
|
-
if (out(out_desc, state->window, state->wsize - left))
|
612
|
-
ret = Z_BUF_ERROR;
|
613
|
-
}
|
614
597
|
goto inf_leave;
|
615
598
|
|
616
599
|
case BAD:
|
617
600
|
ret = Z_DATA_ERROR;
|
618
601
|
goto inf_leave;
|
619
602
|
|
620
|
-
default:
|
603
|
+
default:
|
604
|
+
/* can't happen, but makes compilers happy */
|
621
605
|
ret = Z_STREAM_ERROR;
|
622
606
|
goto inf_leave;
|
623
607
|
}
|
624
608
|
|
625
|
-
/*
|
609
|
+
/* Write leftover output and return unused input */
|
626
610
|
inf_leave:
|
611
|
+
if (left < state->wsize) {
|
612
|
+
if (out(out_desc, state->window, state->wsize - left) &&
|
613
|
+
ret == Z_STREAM_END)
|
614
|
+
ret = Z_BUF_ERROR;
|
615
|
+
}
|
627
616
|
strm->next_in = next;
|
628
617
|
strm->avail_in = have;
|
629
618
|
return ret;
|
630
619
|
}
|
631
620
|
|
632
|
-
int ZEXPORT inflateBackEnd(strm)
|
633
|
-
z_streamp strm;
|
634
|
-
{
|
621
|
+
int ZEXPORT inflateBackEnd(z_streamp strm) {
|
635
622
|
if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
|
636
623
|
return Z_STREAM_ERROR;
|
637
624
|
ZFREE(strm, strm->state);
|
@@ -47,10 +47,7 @@
|
|
47
47
|
requires strm->avail_out >= 258 for each loop to avoid checking for
|
48
48
|
output space.
|
49
49
|
*/
|
50
|
-
void ZLIB_INTERNAL inflate_fast(strm, start)
|
51
|
-
z_streamp strm;
|
52
|
-
unsigned start; /* inflate()'s starting value for strm->avail_out */
|
53
|
-
{
|
50
|
+
void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start) {
|
54
51
|
struct inflate_state FAR *state;
|
55
52
|
z_const unsigned char FAR *in; /* local strm->next_in */
|
56
53
|
z_const unsigned char FAR *last; /* have enough input while in < last */
|
@@ -91,20 +91,7 @@
|
|
91
91
|
# endif
|
92
92
|
#endif
|
93
93
|
|
94
|
-
|
95
|
-
local int inflateStateCheck OF((z_streamp strm));
|
96
|
-
local void fixedtables OF((struct inflate_state FAR *state));
|
97
|
-
local int updatewindow OF((z_streamp strm, const unsigned char FAR *end,
|
98
|
-
unsigned copy));
|
99
|
-
#ifdef BUILDFIXED
|
100
|
-
void makefixed OF((void));
|
101
|
-
#endif
|
102
|
-
local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf,
|
103
|
-
unsigned len));
|
104
|
-
|
105
|
-
local int inflateStateCheck(strm)
|
106
|
-
z_streamp strm;
|
107
|
-
{
|
94
|
+
local int inflateStateCheck(z_streamp strm) {
|
108
95
|
struct inflate_state FAR *state;
|
109
96
|
if (strm == Z_NULL ||
|
110
97
|
strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)
|
@@ -116,9 +103,7 @@ z_streamp strm;
|
|
116
103
|
return 0;
|
117
104
|
}
|
118
105
|
|
119
|
-
int ZEXPORT inflateResetKeep(strm)
|
120
|
-
z_streamp strm;
|
121
|
-
{
|
106
|
+
int ZEXPORT inflateResetKeep(z_streamp strm) {
|
122
107
|
struct inflate_state FAR *state;
|
123
108
|
|
124
109
|
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
|
@@ -142,9 +127,7 @@ z_streamp strm;
|
|
142
127
|
return Z_OK;
|
143
128
|
}
|
144
129
|
|
145
|
-
int ZEXPORT inflateReset(strm)
|
146
|
-
z_streamp strm;
|
147
|
-
{
|
130
|
+
int ZEXPORT inflateReset(z_streamp strm) {
|
148
131
|
struct inflate_state FAR *state;
|
149
132
|
|
150
133
|
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
|
@@ -155,10 +138,7 @@ z_streamp strm;
|
|
155
138
|
return inflateResetKeep(strm);
|
156
139
|
}
|
157
140
|
|
158
|
-
int ZEXPORT inflateReset2(strm, windowBits)
|
159
|
-
z_streamp strm;
|
160
|
-
int windowBits;
|
161
|
-
{
|
141
|
+
int ZEXPORT inflateReset2(z_streamp strm, int windowBits) {
|
162
142
|
int wrap;
|
163
143
|
struct inflate_state FAR *state;
|
164
144
|
|
@@ -168,6 +148,8 @@ int windowBits;
|
|
168
148
|
|
169
149
|
/* extract wrap request from windowBits parameter */
|
170
150
|
if (windowBits < 0) {
|
151
|
+
if (windowBits < -15)
|
152
|
+
return Z_STREAM_ERROR;
|
171
153
|
wrap = 0;
|
172
154
|
windowBits = -windowBits;
|
173
155
|
}
|
@@ -193,12 +175,8 @@ int windowBits;
|
|
193
175
|
return inflateReset(strm);
|
194
176
|
}
|
195
177
|
|
196
|
-
int ZEXPORT inflateInit2_(strm, windowBits,
|
197
|
-
|
198
|
-
int windowBits;
|
199
|
-
const char *version;
|
200
|
-
int stream_size;
|
201
|
-
{
|
178
|
+
int ZEXPORT inflateInit2_(z_streamp strm, int windowBits,
|
179
|
+
const char *version, int stream_size) {
|
202
180
|
int ret;
|
203
181
|
struct inflate_state FAR *state;
|
204
182
|
|
@@ -237,22 +215,17 @@ int stream_size;
|
|
237
215
|
return ret;
|
238
216
|
}
|
239
217
|
|
240
|
-
int ZEXPORT inflateInit_(strm, version,
|
241
|
-
|
242
|
-
const char *version;
|
243
|
-
int stream_size;
|
244
|
-
{
|
218
|
+
int ZEXPORT inflateInit_(z_streamp strm, const char *version,
|
219
|
+
int stream_size) {
|
245
220
|
return inflateInit2_(strm, DEF_WBITS, version, stream_size);
|
246
221
|
}
|
247
222
|
|
248
|
-
int ZEXPORT inflatePrime(strm, bits, value)
|
249
|
-
z_streamp strm;
|
250
|
-
int bits;
|
251
|
-
int value;
|
252
|
-
{
|
223
|
+
int ZEXPORT inflatePrime(z_streamp strm, int bits, int value) {
|
253
224
|
struct inflate_state FAR *state;
|
254
225
|
|
255
226
|
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
|
227
|
+
if (bits == 0)
|
228
|
+
return Z_OK;
|
256
229
|
state = (struct inflate_state FAR *)strm->state;
|
257
230
|
if (bits < 0) {
|
258
231
|
state->hold = 0;
|
@@ -276,9 +249,7 @@ int value;
|
|
276
249
|
used for threaded applications, since the rewriting of the tables and virgin
|
277
250
|
may not be thread-safe.
|
278
251
|
*/
|
279
|
-
local void fixedtables(state)
|
280
|
-
struct inflate_state FAR *state;
|
281
|
-
{
|
252
|
+
local void fixedtables(struct inflate_state FAR *state) {
|
282
253
|
#ifdef BUILDFIXED
|
283
254
|
static int virgin = 1;
|
284
255
|
static code *lenfix, *distfix;
|
@@ -340,7 +311,7 @@ struct inflate_state FAR *state;
|
|
340
311
|
|
341
312
|
a.out > inffixed.h
|
342
313
|
*/
|
343
|
-
void makefixed()
|
314
|
+
void makefixed(void)
|
344
315
|
{
|
345
316
|
unsigned low, size;
|
346
317
|
struct inflate_state state;
|
@@ -394,11 +365,7 @@ void makefixed()
|
|
394
365
|
output will fall in the output data, making match copies simpler and faster.
|
395
366
|
The advantage may be dependent on the size of the processor's data caches.
|
396
367
|
*/
|
397
|
-
local int updatewindow(strm, end, copy)
|
398
|
-
z_streamp strm;
|
399
|
-
const Bytef *end;
|
400
|
-
unsigned copy;
|
401
|
-
{
|
368
|
+
local int updatewindow(z_streamp strm, const Bytef *end, unsigned copy) {
|
402
369
|
struct inflate_state FAR *state;
|
403
370
|
unsigned dist;
|
404
371
|
|
@@ -620,10 +587,7 @@ unsigned copy;
|
|
620
587
|
will return Z_BUF_ERROR if it has not reached the end of the stream.
|
621
588
|
*/
|
622
589
|
|
623
|
-
int ZEXPORT inflate(strm, flush)
|
624
|
-
z_streamp strm;
|
625
|
-
int flush;
|
626
|
-
{
|
590
|
+
int ZEXPORT inflate(z_streamp strm, int flush) {
|
627
591
|
struct inflate_state FAR *state;
|
628
592
|
z_const unsigned char FAR *next; /* next input */
|
629
593
|
unsigned char FAR *put; /* next output */
|
@@ -764,8 +728,9 @@ int flush;
|
|
764
728
|
if (copy > have) copy = have;
|
765
729
|
if (copy) {
|
766
730
|
if (state->head != Z_NULL &&
|
767
|
-
state->head->extra != Z_NULL
|
768
|
-
len = state->head->extra_len - state->length
|
731
|
+
state->head->extra != Z_NULL &&
|
732
|
+
(len = state->head->extra_len - state->length) <
|
733
|
+
state->head->extra_max) {
|
769
734
|
zmemcpy(state->head->extra + len, next,
|
770
735
|
len + copy > state->head->extra_max ?
|
771
736
|
state->head->extra_max - len : copy);
|
@@ -1298,9 +1263,7 @@ int flush;
|
|
1298
1263
|
return ret;
|
1299
1264
|
}
|
1300
1265
|
|
1301
|
-
int ZEXPORT inflateEnd(strm)
|
1302
|
-
z_streamp strm;
|
1303
|
-
{
|
1266
|
+
int ZEXPORT inflateEnd(z_streamp strm) {
|
1304
1267
|
struct inflate_state FAR *state;
|
1305
1268
|
if (inflateStateCheck(strm))
|
1306
1269
|
return Z_STREAM_ERROR;
|
@@ -1312,11 +1275,8 @@ z_streamp strm;
|
|
1312
1275
|
return Z_OK;
|
1313
1276
|
}
|
1314
1277
|
|
1315
|
-
int ZEXPORT inflateGetDictionary(strm, dictionary,
|
1316
|
-
|
1317
|
-
Bytef *dictionary;
|
1318
|
-
uInt *dictLength;
|
1319
|
-
{
|
1278
|
+
int ZEXPORT inflateGetDictionary(z_streamp strm, Bytef *dictionary,
|
1279
|
+
uInt *dictLength) {
|
1320
1280
|
struct inflate_state FAR *state;
|
1321
1281
|
|
1322
1282
|
/* check state */
|
@@ -1335,11 +1295,8 @@ uInt *dictLength;
|
|
1335
1295
|
return Z_OK;
|
1336
1296
|
}
|
1337
1297
|
|
1338
|
-
int ZEXPORT inflateSetDictionary(strm, dictionary,
|
1339
|
-
|
1340
|
-
const Bytef *dictionary;
|
1341
|
-
uInt dictLength;
|
1342
|
-
{
|
1298
|
+
int ZEXPORT inflateSetDictionary(z_streamp strm, const Bytef *dictionary,
|
1299
|
+
uInt dictLength) {
|
1343
1300
|
struct inflate_state FAR *state;
|
1344
1301
|
unsigned long dictid;
|
1345
1302
|
int ret;
|
@@ -1370,10 +1327,7 @@ uInt dictLength;
|
|
1370
1327
|
return Z_OK;
|
1371
1328
|
}
|
1372
1329
|
|
1373
|
-
int ZEXPORT inflateGetHeader(strm, head)
|
1374
|
-
z_streamp strm;
|
1375
|
-
gz_headerp head;
|
1376
|
-
{
|
1330
|
+
int ZEXPORT inflateGetHeader(z_streamp strm, gz_headerp head) {
|
1377
1331
|
struct inflate_state FAR *state;
|
1378
1332
|
|
1379
1333
|
/* check state */
|
@@ -1398,11 +1352,8 @@ gz_headerp head;
|
|
1398
1352
|
called again with more data and the *have state. *have is initialized to
|
1399
1353
|
zero for the first call.
|
1400
1354
|
*/
|
1401
|
-
local unsigned syncsearch(have, buf,
|
1402
|
-
unsigned
|
1403
|
-
const unsigned char FAR *buf;
|
1404
|
-
unsigned len;
|
1405
|
-
{
|
1355
|
+
local unsigned syncsearch(unsigned FAR *have, const unsigned char FAR *buf,
|
1356
|
+
unsigned len) {
|
1406
1357
|
unsigned got;
|
1407
1358
|
unsigned next;
|
1408
1359
|
|
@@ -1421,9 +1372,7 @@ unsigned len;
|
|
1421
1372
|
return next;
|
1422
1373
|
}
|
1423
1374
|
|
1424
|
-
int ZEXPORT inflateSync(strm)
|
1425
|
-
z_streamp strm;
|
1426
|
-
{
|
1375
|
+
int ZEXPORT inflateSync(z_streamp strm) {
|
1427
1376
|
unsigned len; /* number of bytes to look at or looked at */
|
1428
1377
|
int flags; /* temporary to save header status */
|
1429
1378
|
unsigned long in, out; /* temporary to save total_in and total_out */
|
@@ -1438,7 +1387,7 @@ z_streamp strm;
|
|
1438
1387
|
/* if first time, start search in bit buffer */
|
1439
1388
|
if (state->mode != SYNC) {
|
1440
1389
|
state->mode = SYNC;
|
1441
|
-
state->hold
|
1390
|
+
state->hold >>= state->bits & 7;
|
1442
1391
|
state->bits -= state->bits & 7;
|
1443
1392
|
len = 0;
|
1444
1393
|
while (state->bits >= 8) {
|
@@ -1479,9 +1428,7 @@ z_streamp strm;
|
|
1479
1428
|
block. When decompressing, PPP checks that at the end of input packet,
|
1480
1429
|
inflate is waiting for these length bytes.
|
1481
1430
|
*/
|
1482
|
-
int ZEXPORT inflateSyncPoint(strm)
|
1483
|
-
z_streamp strm;
|
1484
|
-
{
|
1431
|
+
int ZEXPORT inflateSyncPoint(z_streamp strm) {
|
1485
1432
|
struct inflate_state FAR *state;
|
1486
1433
|
|
1487
1434
|
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
|
@@ -1489,10 +1436,7 @@ z_streamp strm;
|
|
1489
1436
|
return state->mode == STORED && state->bits == 0;
|
1490
1437
|
}
|
1491
1438
|
|
1492
|
-
int ZEXPORT inflateCopy(dest, source)
|
1493
|
-
z_streamp dest;
|
1494
|
-
z_streamp source;
|
1495
|
-
{
|
1439
|
+
int ZEXPORT inflateCopy(z_streamp dest, z_streamp source) {
|
1496
1440
|
struct inflate_state FAR *state;
|
1497
1441
|
struct inflate_state FAR *copy;
|
1498
1442
|
unsigned char FAR *window;
|
@@ -1536,10 +1480,7 @@ z_streamp source;
|
|
1536
1480
|
return Z_OK;
|
1537
1481
|
}
|
1538
1482
|
|
1539
|
-
int ZEXPORT inflateUndermine(strm, subvert)
|
1540
|
-
z_streamp strm;
|
1541
|
-
int subvert;
|
1542
|
-
{
|
1483
|
+
int ZEXPORT inflateUndermine(z_streamp strm, int subvert) {
|
1543
1484
|
struct inflate_state FAR *state;
|
1544
1485
|
|
1545
1486
|
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
|
@@ -1554,10 +1495,7 @@ int subvert;
|
|
1554
1495
|
#endif
|
1555
1496
|
}
|
1556
1497
|
|
1557
|
-
int ZEXPORT inflateValidate(strm, check)
|
1558
|
-
z_streamp strm;
|
1559
|
-
int check;
|
1560
|
-
{
|
1498
|
+
int ZEXPORT inflateValidate(z_streamp strm, int check) {
|
1561
1499
|
struct inflate_state FAR *state;
|
1562
1500
|
|
1563
1501
|
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
|
@@ -1569,9 +1507,7 @@ int check;
|
|
1569
1507
|
return Z_OK;
|
1570
1508
|
}
|
1571
1509
|
|
1572
|
-
long ZEXPORT inflateMark(strm)
|
1573
|
-
z_streamp strm;
|
1574
|
-
{
|
1510
|
+
long ZEXPORT inflateMark(z_streamp strm) {
|
1575
1511
|
struct inflate_state FAR *state;
|
1576
1512
|
|
1577
1513
|
if (inflateStateCheck(strm))
|
@@ -1582,9 +1518,7 @@ z_streamp strm;
|
|
1582
1518
|
(state->mode == MATCH ? state->was - state->length : 0));
|
1583
1519
|
}
|
1584
1520
|
|
1585
|
-
unsigned long ZEXPORT inflateCodesUsed(strm)
|
1586
|
-
z_streamp strm;
|
1587
|
-
{
|
1521
|
+
unsigned long ZEXPORT inflateCodesUsed(z_streamp strm) {
|
1588
1522
|
struct inflate_state FAR *state;
|
1589
1523
|
if (inflateStateCheck(strm)) return (unsigned long)-1;
|
1590
1524
|
state = (struct inflate_state FAR *)strm->state;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/* inftrees.c -- generate Huffman trees for efficient decoding
|
2
|
-
* Copyright (C) 1995-
|
2
|
+
* Copyright (C) 1995-2024 Mark Adler
|
3
3
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
4
4
|
*/
|
5
5
|
|
@@ -9,7 +9,7 @@
|
|
9
9
|
#define MAXBITS 15
|
10
10
|
|
11
11
|
const char inflate_copyright[] =
|
12
|
-
" inflate 1.
|
12
|
+
" inflate 1.3.1 Copyright 1995-2024 Mark Adler ";
|
13
13
|
/*
|
14
14
|
If you use the zlib library in a product, an acknowledgment is welcome
|
15
15
|
in the documentation of your product. If for some reason you cannot
|
@@ -29,14 +29,9 @@ const char inflate_copyright[] =
|
|
29
29
|
table index bits. It will differ if the request is greater than the
|
30
30
|
longest code or if it is less than the shortest code.
|
31
31
|
*/
|
32
|
-
int ZLIB_INTERNAL inflate_table(type,
|
33
|
-
|
34
|
-
unsigned short FAR *
|
35
|
-
unsigned codes;
|
36
|
-
code FAR * FAR *table;
|
37
|
-
unsigned FAR *bits;
|
38
|
-
unsigned short FAR *work;
|
39
|
-
{
|
32
|
+
int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
|
33
|
+
unsigned codes, code FAR * FAR *table,
|
34
|
+
unsigned FAR *bits, unsigned short FAR *work) {
|
40
35
|
unsigned len; /* a code's length in bits */
|
41
36
|
unsigned sym; /* index of code symbols */
|
42
37
|
unsigned min, max; /* minimum and maximum code lengths */
|
@@ -62,7 +57,7 @@ unsigned short FAR *work;
|
|
62
57
|
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
|
63
58
|
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
|
64
59
|
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
|
65
|
-
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16,
|
60
|
+
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 203, 77};
|
66
61
|
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
|
67
62
|
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
|
68
63
|
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
|
@@ -38,11 +38,11 @@ typedef struct {
|
|
38
38
|
/* Maximum size of the dynamic table. The maximum number of code structures is
|
39
39
|
1444, which is the sum of 852 for literal/length codes and 592 for distance
|
40
40
|
codes. These values were found by exhaustive searches using the program
|
41
|
-
examples/enough.c found in the zlib
|
41
|
+
examples/enough.c found in the zlib distribution. The arguments to that
|
42
42
|
program are the number of symbols, the initial root table size, and the
|
43
43
|
maximum bit length of a code. "enough 286 9 15" for literal/length codes
|
44
|
-
returns
|
45
|
-
|
44
|
+
returns 852, and "enough 30 6 15" for distance codes returns 592. The
|
45
|
+
initial root table size (9 or 6) is found in the fifth argument of the
|
46
46
|
inflate_table() calls in inflate.c and infback.c. If the root table size is
|
47
47
|
changed, then these maximum sizes would be need to be recalculated and
|
48
48
|
updated. */
|
@@ -57,6 +57,6 @@ typedef enum {
|
|
57
57
|
DISTS
|
58
58
|
} codetype;
|
59
59
|
|
60
|
-
int ZLIB_INTERNAL inflate_table
|
61
|
-
|
62
|
-
|
60
|
+
int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
|
61
|
+
unsigned codes, code FAR * FAR *table,
|
62
|
+
unsigned FAR *bits, unsigned short FAR *work);
|