Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 894598
Collapse All | Expand All

(-)a/adler32.c (-20 / +5 lines)
Lines 60-69 Link Here
60
#endif
60
#endif
61
61
62
/* ========================================================================= */
62
/* ========================================================================= */
63
uLong ZEXPORT adler32_z(adler, buf, len)
63
uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, z_size_t len)
64
    uLong adler;
65
    const Bytef *buf;
66
    z_size_t len;
67
{
64
{
68
    unsigned long sum2;
65
    unsigned long sum2;
69
    unsigned n;
66
    unsigned n;
Lines 131-149 Link Here
131
}
128
}
132
129
133
/* ========================================================================= */
130
/* ========================================================================= */
134
uLong ZEXPORT adler32(adler, buf, len)
131
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len)
135
    uLong adler;
136
    const Bytef *buf;
137
    uInt len;
138
{
132
{
139
    return adler32_z(adler, buf, len);
133
    return adler32_z(adler, buf, len);
140
}
134
}
141
135
142
/* ========================================================================= */
136
/* ========================================================================= */
143
local uLong adler32_combine_(adler1, adler2, len2)
137
local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2)
144
    uLong adler1;
145
    uLong adler2;
146
    z_off64_t len2;
147
{
138
{
148
    unsigned long sum1;
139
    unsigned long sum1;
149
    unsigned long sum2;
140
    unsigned long sum2;
Lines 169-186 Link Here
169
}
160
}
170
161
171
/* ========================================================================= */
162
/* ========================================================================= */
172
uLong ZEXPORT adler32_combine(adler1, adler2, len2)
163
uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, z_off_t len2)
173
    uLong adler1;
174
    uLong adler2;
175
    z_off_t len2;
176
{
164
{
177
    return adler32_combine_(adler1, adler2, len2);
165
    return adler32_combine_(adler1, adler2, len2);
178
}
166
}
179
167
180
uLong ZEXPORT adler32_combine64(adler1, adler2, len2)
168
uLong ZEXPORT adler32_combine64(uLong adler1, uLong adler2, z_off64_t len2)
181
    uLong adler1;
182
    uLong adler2;
183
    z_off64_t len2;
184
{
169
{
185
    return adler32_combine_(adler1, adler2, len2);
170
    return adler32_combine_(adler1, adler2, len2);
186
}
171
}
(-)a/contrib/minizip/ioapi.c (-2 / +1 lines)
Lines 231-238 Link Here
231
    return ret;
231
    return ret;
232
}
232
}
233
233
234
void fill_fopen_filefunc (pzlib_filefunc_def)
234
void fill_fopen_filefunc (zlib_filefunc_def* pzlib_filefunc_def)
235
  zlib_filefunc_def* pzlib_filefunc_def;
236
{
235
{
237
    pzlib_filefunc_def->zopen_file = fopen_file_func;
236
    pzlib_filefunc_def->zopen_file = fopen_file_func;
238
    pzlib_filefunc_def->zread_file = fread_file_func;
237
    pzlib_filefunc_def->zread_file = fread_file_func;
(-)a/crc32.c (-62 / +23 lines)
Lines 123-130 Link Here
123
  instruction, if one is available. This assumes that word_t is either 32 bits
123
  instruction, if one is available. This assumes that word_t is either 32 bits
124
  or 64 bits.
124
  or 64 bits.
125
 */
125
 */
126
local z_word_t byte_swap(word)
126
local z_word_t byte_swap(z_word_t word)
127
    z_word_t word;
128
{
127
{
129
#  if W == 8
128
#  if W == 8
130
    return
129
    return
Lines 223-230 Link Here
223
/* Test and set. Alas, not atomic, but tries to minimize the period of
222
/* Test and set. Alas, not atomic, but tries to minimize the period of
224
   vulnerability. */
223
   vulnerability. */
225
local int test_and_set OF((int volatile *));
224
local int test_and_set OF((int volatile *));
226
local int test_and_set(flag)
225
local int test_and_set(int volatile *flag)
227
    int volatile *flag;
228
{
226
{
229
    int was;
227
    int was;
230
228
Lines 234-242 Link Here
234
}
232
}
235
233
236
/* Run the provided init() function once. This is not thread-safe. */
234
/* Run the provided init() function once. This is not thread-safe. */
237
local void once(state, init)
235
local void once(once_t *state, void (*init)(void))
238
    once_t *state;
239
    void (*init)(void);
240
{
236
{
241
    if (!state->done) {
237
    if (!state->done) {
242
        if (test_and_set(&state->begun))
238
        if (test_and_set(&state->begun))
Lines 447-456 Link Here
447
   Write the 32-bit values in table[0..k-1] to out, five per line in
443
   Write the 32-bit values in table[0..k-1] to out, five per line in
448
   hexadecimal separated by commas.
444
   hexadecimal separated by commas.
449
 */
445
 */
450
local void write_table(out, table, k)
446
local void write_table(FILE *out, const z_crc_t FAR *table, int k)
451
    FILE *out;
452
    const z_crc_t FAR *table;
453
    int k;
454
{
447
{
455
    int n;
448
    int n;
456
449
Lines 464-473 Link Here
464
   Write the high 32-bits of each value in table[0..k-1] to out, five per line
457
   Write the high 32-bits of each value in table[0..k-1] to out, five per line
465
   in hexadecimal separated by commas.
458
   in hexadecimal separated by commas.
466
 */
459
 */
467
local void write_table32hi(out, table, k)
460
local void write_table32hi(FILE *out, const z_word_t FAR *table, int k)
468
FILE *out;
469
const z_word_t FAR *table;
470
int k;
471
{
461
{
472
    int n;
462
    int n;
473
463
Lines 484-493 Link Here
484
  bits. If not, then the type cast and format string can be adjusted
474
  bits. If not, then the type cast and format string can be adjusted
485
  accordingly.
475
  accordingly.
486
 */
476
 */
487
local void write_table64(out, table, k)
477
local void write_table64(FILE *out, const z_word_t FAR *table, int k)
488
    FILE *out;
489
    const z_word_t FAR *table;
490
    int k;
491
{
478
{
492
    int n;
479
    int n;
493
480
Lines 511-521 Link Here
511
  Generate the little and big-endian braid tables for the given n and z_word_t
498
  Generate the little and big-endian braid tables for the given n and z_word_t
512
  size w. Each array must have room for w blocks of 256 elements.
499
  size w. Each array must have room for w blocks of 256 elements.
513
 */
500
 */
514
local void braid(ltl, big, n, w)
501
local void braid(z_crc_t ltl[][256],z_word_t big[][256], int n, int w)
515
    z_crc_t ltl[][256];
516
    z_word_t big[][256];
517
    int n;
518
    int w;
519
{
502
{
520
    int k;
503
    int k;
521
    z_crc_t i, p, q;
504
    z_crc_t i, p, q;
Lines 548-556 Link Here
548
  Return a(x) multiplied by b(x) modulo p(x), where p(x) is the CRC polynomial,
531
  Return a(x) multiplied by b(x) modulo p(x), where p(x) is the CRC polynomial,
549
  reflected. For speed, this requires that a not be zero.
532
  reflected. For speed, this requires that a not be zero.
550
 */
533
 */
551
local z_crc_t multmodp(a, b)
534
local z_crc_t multmodp(z_crc_t a, z_crc_t b)
552
    z_crc_t a;
553
    z_crc_t b;
554
{
535
{
555
    z_crc_t m, p;
536
    z_crc_t m, p;
556
537
Lines 572-580 Link Here
572
  Return x^(n * 2^k) modulo p(x). Requires that x2n_table[] has been
553
  Return x^(n * 2^k) modulo p(x). Requires that x2n_table[] has been
573
  initialized.
554
  initialized.
574
 */
555
 */
575
local z_crc_t x2nmodp(n, k)
556
local z_crc_t x2nmodp(z_off64_t n, unsigned k)
576
    z_off64_t n;
577
    unsigned k;
578
{
557
{
579
    z_crc_t p;
558
    z_crc_t p;
580
559
Lines 619-628 Link Here
619
#define Z_BATCH_ZEROS 0xa10d3d0c    /* computed from Z_BATCH = 3990 */
598
#define Z_BATCH_ZEROS 0xa10d3d0c    /* computed from Z_BATCH = 3990 */
620
#define Z_BATCH_MIN 800             /* fewest words in a final batch */
599
#define Z_BATCH_MIN 800             /* fewest words in a final batch */
621
600
622
unsigned long ZEXPORT crc32_z(crc, buf, len)
601
unsigned long ZEXPORT crc32_z(unsigned long crc,
623
    unsigned long crc;
602
                              const unsigned char FAR *buf,
624
    const unsigned char FAR *buf;
603
                              z_size_t len)
625
    z_size_t len;
626
{
604
{
627
    z_crc_t val;
605
    z_crc_t val;
628
    z_word_t crc1, crc2;
606
    z_word_t crc1, crc2;
Lines 723-730 Link Here
723
  least-significant byte of the word as the first byte of data, without any pre
701
  least-significant byte of the word as the first byte of data, without any pre
724
  or post conditioning. This is used to combine the CRCs of each braid.
702
  or post conditioning. This is used to combine the CRCs of each braid.
725
 */
703
 */
726
local z_crc_t crc_word(data)
704
local z_crc_t crc_word(z_word_t data)
727
    z_word_t data;
728
{
705
{
729
    int k;
706
    int k;
730
    for (k = 0; k < W; k++)
707
    for (k = 0; k < W; k++)
Lines 732-739 Link Here
732
    return (z_crc_t)data;
709
    return (z_crc_t)data;
733
}
710
}
734
711
735
local z_word_t crc_word_big(data)
712
local z_word_t crc_word_big(z_word_t data)
736
    z_word_t data;
737
{
713
{
738
    int k;
714
    int k;
739
    for (k = 0; k < W; k++)
715
    for (k = 0; k < W; k++)
Lines 745-754 Link Here
745
#endif
721
#endif
746
722
747
/* ========================================================================= */
723
/* ========================================================================= */
748
unsigned long ZEXPORT crc32_z(crc, buf, len)
724
unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf,
749
    unsigned long crc;
725
                              z_size_t len)
750
    const unsigned char FAR *buf;
751
    z_size_t len;
752
{
726
{
753
    /* Return initial CRC, if requested. */
727
    /* Return initial CRC, if requested. */
754
    if (buf == Z_NULL) return 0;
728
    if (buf == Z_NULL) return 0;
Lines 1069-1087 Link Here
1069
#endif
1043
#endif
1070
1044
1071
/* ========================================================================= */
1045
/* ========================================================================= */
1072
unsigned long ZEXPORT crc32(crc, buf, len)
1046
unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf,
1073
    unsigned long crc;
1047
                            uInt len)
1074
    const unsigned char FAR *buf;
1075
    uInt len;
1076
{
1048
{
1077
    return crc32_z(crc, buf, len);
1049
    return crc32_z(crc, buf, len);
1078
}
1050
}
1079
1051
1080
/* ========================================================================= */
1052
/* ========================================================================= */
1081
uLong ZEXPORT crc32_combine64(crc1, crc2, len2)
1053
uLong ZEXPORT crc32_combine64(uLong crc1, uLong crc2, z_off64_t len2)
1082
    uLong crc1;
1083
    uLong crc2;
1084
    z_off64_t len2;
1085
{
1054
{
1086
#ifdef DYNAMIC_CRC_TABLE
1055
#ifdef DYNAMIC_CRC_TABLE
1087
    once(&made, make_crc_table);
1056
    once(&made, make_crc_table);
Lines 1090-1106 Link Here
1090
}
1059
}
1091
1060
1092
/* ========================================================================= */
1061
/* ========================================================================= */
1093
uLong ZEXPORT crc32_combine(crc1, crc2, len2)
1062
uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2)
1094
    uLong crc1;
1095
    uLong crc2;
1096
    z_off_t len2;
1097
{
1063
{
1098
    return crc32_combine64(crc1, crc2, (z_off64_t)len2);
1064
    return crc32_combine64(crc1, crc2, (z_off64_t)len2);
1099
}
1065
}
1100
1066
1101
/* ========================================================================= */
1067
/* ========================================================================= */
1102
uLong ZEXPORT crc32_combine_gen64(len2)
1068
uLong ZEXPORT crc32_combine_gen64(z_off64_t len2)
1103
    z_off64_t len2;
1104
{
1069
{
1105
#ifdef DYNAMIC_CRC_TABLE
1070
#ifdef DYNAMIC_CRC_TABLE
1106
    once(&made, make_crc_table);
1071
    once(&made, make_crc_table);
Lines 1109-1125 Link Here
1109
}
1074
}
1110
1075
1111
/* ========================================================================= */
1076
/* ========================================================================= */
1112
uLong ZEXPORT crc32_combine_gen(len2)
1077
uLong ZEXPORT crc32_combine_gen(z_off_t len2)
1113
    z_off_t len2;
1114
{
1078
{
1115
    return crc32_combine_gen64((z_off64_t)len2);
1079
    return crc32_combine_gen64((z_off64_t)len2);
1116
}
1080
}
1117
1081
1118
/* ========================================================================= */
1082
/* ========================================================================= */
1119
uLong ZEXPORT crc32_combine_op(crc1, crc2, op)
1083
uLong ZEXPORT crc32_combine_op(uLong crc1, uLong crc2, uLong op)
1120
    uLong crc1;
1121
    uLong crc2;
1122
    uLong op;
1123
{
1084
{
1124
    return multmodp(op, crc1) ^ (crc2 & 0xffffffff);
1085
    return multmodp(op, crc1) ^ (crc2 & 0xffffffff);
1125
}
1086
}
(-)a/deflate.c (-57 / +16 lines)
Lines 195-202 Link Here
195
 * bit values at the expense of memory usage). We slide even when level == 0 to
195
 * bit values at the expense of memory usage). We slide even when level == 0 to
196
 * keep the hash table consistent if we switch back to level > 0 later.
196
 * keep the hash table consistent if we switch back to level > 0 later.
197
 */
197
 */
198
local void slide_hash(s)
198
local void slide_hash(deflate_state *s)
199
    deflate_state *s;
200
{
199
{
201
    unsigned n, m;
200
    unsigned n, m;
202
    Posf *p;
201
    Posf *p;
Lines 222-232 Link Here
222
}
221
}
223
222
224
/* ========================================================================= */
223
/* ========================================================================= */
225
int ZEXPORT deflateInit_(strm, level, version, stream_size)
224
int ZEXPORT deflateInit_(z_streamp strm, int level, const char * version, int stream_size)
226
    z_streamp strm;
227
    int level;
228
    const char *version;
229
    int stream_size;
230
{
225
{
231
    return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL,
226
    return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL,
232
                         Z_DEFAULT_STRATEGY, version, stream_size);
227
                         Z_DEFAULT_STRATEGY, version, stream_size);
Lines 234-249 Link Here
234
}
229
}
235
230
236
/* ========================================================================= */
231
/* ========================================================================= */
237
int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
232
int ZEXPORT deflateInit2_(z_streamp strm, int level, int method, int windowBits, int memLevel, int strategy,
238
                  version, stream_size)
233
                  const char *version, int stream_size)
239
    z_streamp strm;
240
    int  level;
241
    int  method;
242
    int  windowBits;
243
    int  memLevel;
244
    int  strategy;
245
    const char *version;
246
    int stream_size;
247
{
234
{
248
    deflate_state *s;
235
    deflate_state *s;
249
    int wrap = 1;
236
    int wrap = 1;
Lines 602-611 Link Here
602
}
589
}
603
590
604
/* ========================================================================= */
591
/* ========================================================================= */
605
int ZEXPORT deflateParams(strm, level, strategy)
592
int ZEXPORT deflateParams(z_streamp strm, int level, int strategy)
606
    z_streamp strm;
607
    int level;
608
    int strategy;
609
{
593
{
610
    deflate_state *s;
594
    deflate_state *s;
611
    compress_func func;
595
    compress_func func;
Lines 651-662 Link Here
651
}
635
}
652
636
653
/* ========================================================================= */
637
/* ========================================================================= */
654
int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain)
638
int ZEXPORT deflateTune(z_streamp strm, int good_length, int max_lazy, int nice_length, int max_chain)
655
    z_streamp strm;
656
    int good_length;
657
    int max_lazy;
658
    int nice_length;
659
    int max_chain;
660
{
639
{
661
    deflate_state *s;
640
    deflate_state *s;
662
641
Lines 693-701 Link Here
693
 *
672
 *
694
 * Shifts are used to approximate divisions, for speed.
673
 * Shifts are used to approximate divisions, for speed.
695
 */
674
 */
696
uLong ZEXPORT deflateBound(strm, sourceLen)
675
uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen)
697
    z_streamp strm;
698
    uLong sourceLen;
699
{
676
{
700
    deflate_state *s;
677
    deflate_state *s;
701
    uLong fixedlen, storelen, wraplen;
678
    uLong fixedlen, storelen, wraplen;
Lines 779-786 Link Here
779
 * applications may wish to modify it to avoid allocating a large
756
 * applications may wish to modify it to avoid allocating a large
780
 * strm->next_out buffer and copying into it. (See also read_buf()).
757
 * strm->next_out buffer and copying into it. (See also read_buf()).
781
 */
758
 */
782
local void flush_pending(strm)
759
local void flush_pending(z_streamp strm)
783
    z_streamp strm;
784
{
760
{
785
    unsigned len;
761
    unsigned len;
786
    deflate_state *s = strm->state;
762
    deflate_state *s = strm->state;
Lines 1275-1283 Link Here
1275
 *   string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
1251
 *   string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
1276
 * OUT assertion: the match length is not greater than s->lookahead.
1252
 * OUT assertion: the match length is not greater than s->lookahead.
1277
 */
1253
 */
1278
local uInt longest_match(s, cur_match)
1254
local uInt longest_match(deflate_state *s, IPos cur_match /* current match */)
1279
    deflate_state *s;
1280
    IPos cur_match;                             /* current match */
1281
{
1255
{
1282
    unsigned chain_length = s->max_chain_length;/* max hash chain length */
1256
    unsigned chain_length = s->max_chain_length;/* max hash chain length */
1283
    register Bytef *scan = s->window + s->strstart; /* current string */
1257
    register Bytef *scan = s->window + s->strstart; /* current string */
Lines 1426-1434 Link Here
1426
/* ---------------------------------------------------------------------------
1400
/* ---------------------------------------------------------------------------
1427
 * Optimized version for FASTEST only
1401
 * Optimized version for FASTEST only
1428
 */
1402
 */
1429
local uInt longest_match(s, cur_match)
1403
local uInt longest_match(deflate_state *s, IPos cur_match /* current match */)
1430
    deflate_state *s;
1431
    IPos cur_match;                             /* current match */
1432
{
1404
{
1433
    register Bytef *scan = s->window + s->strstart; /* current string */
1405
    register Bytef *scan = s->window + s->strstart; /* current string */
1434
    register Bytef *match;                       /* matched string */
1406
    register Bytef *match;                       /* matched string */
Lines 1490-1499 Link Here
1490
/* ===========================================================================
1462
/* ===========================================================================
1491
 * Check that the match at match_start is indeed a match.
1463
 * Check that the match at match_start is indeed a match.
1492
 */
1464
 */
1493
local void check_match(s, start, match, length)
1465
local void check_match(deflate_state *s, IPos start, IPos match, int length)
1494
    deflate_state *s;
1495
    IPos start, match;
1496
    int length;
1497
{
1466
{
1498
    /* check that the match is indeed a match */
1467
    /* check that the match is indeed a match */
1499
    if (zmemcmp(s->window + match,
1468
    if (zmemcmp(s->window + match,
Lines 1687-1695 Link Here
1687
 * copied. It is most efficient with large input and output buffers, which
1656
 * copied. It is most efficient with large input and output buffers, which
1688
 * maximizes the opportunities to have a single copy from next_in to next_out.
1657
 * maximizes the opportunities to have a single copy from next_in to next_out.
1689
 */
1658
 */
1690
local block_state deflate_stored(s, flush)
1659
local block_state deflate_stored(deflate_state *s, int flush)
1691
    deflate_state *s;
1692
    int flush;
1693
{
1660
{
1694
    /* Smallest worthy block size when not flushing or finishing. By default
1661
    /* Smallest worthy block size when not flushing or finishing. By default
1695
     * this is 32K. This can be as small as 507 bytes for memLevel == 1. For
1662
     * this is 32K. This can be as small as 507 bytes for memLevel == 1. For
Lines 1874-1882 Link Here
1874
 * new strings in the dictionary only for unmatched strings or for short
1841
 * new strings in the dictionary only for unmatched strings or for short
1875
 * matches. It is used only for the fast compression options.
1842
 * matches. It is used only for the fast compression options.
1876
 */
1843
 */
1877
local block_state deflate_fast(s, flush)
1844
local block_state deflate_fast(deflate_state *s, int flush)
1878
    deflate_state *s;
1879
    int flush;
1880
{
1845
{
1881
    IPos hash_head;       /* head of the hash chain */
1846
    IPos hash_head;       /* head of the hash chain */
1882
    int bflush;           /* set if current block must be flushed */
1847
    int bflush;           /* set if current block must be flushed */
Lines 1976-1984 Link Here
1976
 * evaluation for matches: a match is finally adopted only if there is
1941
 * evaluation for matches: a match is finally adopted only if there is
1977
 * no better match at the next window position.
1942
 * no better match at the next window position.
1978
 */
1943
 */
1979
local block_state deflate_slow(s, flush)
1944
local block_state deflate_slow(deflate_state *s, int flush)
1980
    deflate_state *s;
1981
    int flush;
1982
{
1945
{
1983
    IPos hash_head;          /* head of hash chain */
1946
    IPos hash_head;          /* head of hash chain */
1984
    int bflush;              /* set if current block must be flushed */
1947
    int bflush;              /* set if current block must be flushed */
Lines 2107-2115 Link Here
2107
 * one.  Do not maintain a hash table.  (It will be regenerated if this run of
2070
 * one.  Do not maintain a hash table.  (It will be regenerated if this run of
2108
 * deflate switches away from Z_RLE.)
2071
 * deflate switches away from Z_RLE.)
2109
 */
2072
 */
2110
local block_state deflate_rle(s, flush)
2073
local block_state deflate_rle(deflate_state *s, int flush)
2111
    deflate_state *s;
2112
    int flush;
2113
{
2074
{
2114
    int bflush;             /* set if current block must be flushed */
2075
    int bflush;             /* set if current block must be flushed */
2115
    uInt prev;              /* byte at distance one to match */
2076
    uInt prev;              /* byte at distance one to match */
Lines 2181-2189 Link Here
2181
 * For Z_HUFFMAN_ONLY, do not look for matches.  Do not maintain a hash table.
2142
 * For Z_HUFFMAN_ONLY, do not look for matches.  Do not maintain a hash table.
2182
 * (It will be regenerated if this run of deflate switches away from Huffman.)
2143
 * (It will be regenerated if this run of deflate switches away from Huffman.)
2183
 */
2144
 */
2184
local block_state deflate_huff(s, flush)
2145
local block_state deflate_huff(deflate_state *s, int flush)
2185
    deflate_state *s;
2186
    int flush;
2187
{
2146
{
2188
    int bflush;             /* set if current block must be flushed */
2147
    int bflush;             /* set if current block must be flushed */
2189
2148
(-)a/gzclose.c (-2 / +1 lines)
Lines 8-15 Link Here
8
/* gzclose() is in a separate file so that it is linked in only if it is used.
8
/* gzclose() is in a separate file so that it is linked in only if it is used.
9
   That way the other gzclose functions can be used instead to avoid linking in
9
   That way the other gzclose functions can be used instead to avoid linking in
10
   unneeded compression or decompression routines. */
10
   unneeded compression or decompression routines. */
11
int ZEXPORT gzclose(file)
11
int ZEXPORT gzclose(gzFile file)
12
    gzFile file;
13
{
12
{
14
#ifndef NO_GZCOMPRESS
13
#ifndef NO_GZCOMPRESS
15
    gz_statep state;
14
    gz_statep state;
(-)a/gzlib.c (-50 / +18 lines)
Lines 72-79 Link Here
72
#endif /* UNDER_CE */
72
#endif /* UNDER_CE */
73
73
74
/* Reset gzip file state */
74
/* Reset gzip file state */
75
local void gz_reset(state)
75
local void gz_reset(gz_statep state)
76
    gz_statep state;
77
{
76
{
78
    state->x.have = 0;              /* no output data available */
77
    state->x.have = 0;              /* no output data available */
79
    if (state->mode == GZ_READ) {   /* for reading ... */
78
    if (state->mode == GZ_READ) {   /* for reading ... */
Lines 90-99 Link Here
90
}
89
}
91
90
92
/* Open a gzip file either by name or file descriptor. */
91
/* Open a gzip file either by name or file descriptor. */
93
local gzFile gz_open(path, fd, mode)
92
local gzFile gz_open(const void *path, int fd, const char *mode)
94
    const void *path;
95
    int fd;
96
    const char *mode;
97
{
93
{
98
    gz_statep state;
94
    gz_statep state;
99
    z_size_t len;
95
    z_size_t len;
Lines 269-293 Link Here
269
}
265
}
270
266
271
/* -- see zlib.h -- */
267
/* -- see zlib.h -- */
272
gzFile ZEXPORT gzopen(path, mode)
268
gzFile ZEXPORT gzopen(const char *path, const char *mode)
273
    const char *path;
274
    const char *mode;
275
{
269
{
276
    return gz_open(path, -1, mode);
270
    return gz_open(path, -1, mode);
277
}
271
}
278
272
279
/* -- see zlib.h -- */
273
/* -- see zlib.h -- */
280
gzFile ZEXPORT gzopen64(path, mode)
274
gzFile ZEXPORT gzopen64(const char *path, const char *mode)
281
    const char *path;
282
    const char *mode;
283
{
275
{
284
    return gz_open(path, -1, mode);
276
    return gz_open(path, -1, mode);
285
}
277
}
286
278
287
/* -- see zlib.h -- */
279
/* -- see zlib.h -- */
288
gzFile ZEXPORT gzdopen(fd, mode)
280
gzFile ZEXPORT gzdopen(int fd, const char *mode)
289
    int fd;
290
    const char *mode;
291
{
281
{
292
    char *path;         /* identifier for error messages */
282
    char *path;         /* identifier for error messages */
293
    gzFile gz;
283
    gzFile gz;
Lines 306-323 Link Here
306
296
307
/* -- see zlib.h -- */
297
/* -- see zlib.h -- */
308
#ifdef WIDECHAR
298
#ifdef WIDECHAR
309
gzFile ZEXPORT gzopen_w(path, mode)
299
gzFile ZEXPORT gzopen_w(const wchar_t *path, const char *mode)
310
    const wchar_t *path;
311
    const char *mode;
312
{
300
{
313
    return gz_open(path, -2, mode);
301
    return gz_open(path, -2, mode);
314
}
302
}
315
#endif
303
#endif
316
304
317
/* -- see zlib.h -- */
305
/* -- see zlib.h -- */
318
int ZEXPORT gzbuffer(file, size)
306
int ZEXPORT gzbuffer(gzFile file, unsigned size)
319
    gzFile file;
320
    unsigned size;
321
{
307
{
322
    gz_statep state;
308
    gz_statep state;
323
309
Lines 342-349 Link Here
342
}
328
}
343
329
344
/* -- see zlib.h -- */
330
/* -- see zlib.h -- */
345
int ZEXPORT gzrewind(file)
331
int ZEXPORT gzrewind(gzFile file)
346
    gzFile file;
347
{
332
{
348
    gz_statep state;
333
    gz_statep state;
349
334
Lines 365-374 Link Here
365
}
350
}
366
351
367
/* -- see zlib.h -- */
352
/* -- see zlib.h -- */
368
z_off64_t ZEXPORT gzseek64(file, offset, whence)
353
z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence)
369
    gzFile file;
370
    z_off64_t offset;
371
    int whence;
372
{
354
{
373
    unsigned n;
355
    unsigned n;
374
    z_off64_t ret;
356
    z_off64_t ret;
Lines 442-451 Link Here
442
}
424
}
443
425
444
/* -- see zlib.h -- */
426
/* -- see zlib.h -- */
445
z_off_t ZEXPORT gzseek(file, offset, whence)
427
z_off_t ZEXPORT gzseek(gzFile file, z_off_t offset, int whence)
446
    gzFile file;
447
    z_off_t offset;
448
    int whence;
449
{
428
{
450
    z_off64_t ret;
429
    z_off64_t ret;
451
430
Lines 454-461 Link Here
454
}
433
}
455
434
456
/* -- see zlib.h -- */
435
/* -- see zlib.h -- */
457
z_off64_t ZEXPORT gztell64(file)
436
z_off64_t ZEXPORT gztell64(gzFile file)
458
    gzFile file;
459
{
437
{
460
    gz_statep state;
438
    gz_statep state;
461
439
Lines 471-478 Link Here
471
}
449
}
472
450
473
/* -- see zlib.h -- */
451
/* -- see zlib.h -- */
474
z_off_t ZEXPORT gztell(file)
452
z_off_t ZEXPORT gztell(gzFile file)
475
    gzFile file;
476
{
453
{
477
    z_off64_t ret;
454
    z_off64_t ret;
478
455
Lines 481-488 Link Here
481
}
458
}
482
459
483
/* -- see zlib.h -- */
460
/* -- see zlib.h -- */
484
z_off64_t ZEXPORT gzoffset64(file)
461
z_off64_t ZEXPORT gzoffset64(gzFile file)
485
    gzFile file;
486
{
462
{
487
    z_off64_t offset;
463
    z_off64_t offset;
488
    gz_statep state;
464
    gz_statep state;
Lines 504-511 Link Here
504
}
480
}
505
481
506
/* -- see zlib.h -- */
482
/* -- see zlib.h -- */
507
z_off_t ZEXPORT gzoffset(file)
483
z_off_t ZEXPORT gzoffset(gzFile file)
508
    gzFile file;
509
{
484
{
510
    z_off64_t ret;
485
    z_off64_t ret;
511
486
Lines 514-521 Link Here
514
}
489
}
515
490
516
/* -- see zlib.h -- */
491
/* -- see zlib.h -- */
517
int ZEXPORT gzeof(file)
492
int ZEXPORT gzeof(gzFile file)
518
    gzFile file;
519
{
493
{
520
    gz_statep state;
494
    gz_statep state;
521
495
Lines 531-539 Link Here
531
}
505
}
532
506
533
/* -- see zlib.h -- */
507
/* -- see zlib.h -- */
534
const char * ZEXPORT gzerror(file, errnum)
508
const char * ZEXPORT gzerror(gzFile file, int *errnum)
535
    gzFile file;
536
    int *errnum;
537
{
509
{
538
    gz_statep state;
510
    gz_statep state;
539
511
Lines 552-559 Link Here
552
}
524
}
553
525
554
/* -- see zlib.h -- */
526
/* -- see zlib.h -- */
555
void ZEXPORT gzclearerr(file)
527
void ZEXPORT gzclearerr(gzFile file)
556
    gzFile file;
557
{
528
{
558
    gz_statep state;
529
    gz_statep state;
559
530
Lines 578-587 Link Here
578
   memory).  Simply save the error message as a static string.  If there is an
549
   memory).  Simply save the error message as a static string.  If there is an
579
   allocation failure constructing the error message, then convert the error to
550
   allocation failure constructing the error message, then convert the error to
580
   out of memory. */
551
   out of memory. */
581
void ZLIB_INTERNAL gz_error(state, err, msg)
552
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg)
582
    gz_statep state;
583
    int err;
584
    const char *msg;
585
{
553
{
586
    /* free previously allocated message and clear */
554
    /* free previously allocated message and clear */
587
    if (state->msg != NULL) {
555
    if (state->msg != NULL) {
(-)a/gzread.c (-42 / +16 lines)
Lines 18-28 Link Here
18
   state->fd, and update state->eof, state->err, and state->msg as appropriate.
18
   state->fd, and update state->eof, state->err, and state->msg as appropriate.
19
   This function needs to loop on read(), since read() is not guaranteed to
19
   This function needs to loop on read(), since read() is not guaranteed to
20
   read the number of bytes requested, depending on the type of descriptor. */
20
   read the number of bytes requested, depending on the type of descriptor. */
21
local int gz_load(state, buf, len, have)
21
local int gz_load(gz_statep state, unsigned char *buf,
22
    gz_statep state;
22
                  unsigned len, unsigned *have)
23
    unsigned char *buf;
24
    unsigned len;
25
    unsigned *have;
26
{
23
{
27
    int ret;
24
    int ret;
28
    unsigned get, max = ((unsigned)-1 >> 2) + 1;
25
    unsigned get, max = ((unsigned)-1 >> 2) + 1;
Lines 53-60 Link Here
53
   If strm->avail_in != 0, then the current data is moved to the beginning of
50
   If strm->avail_in != 0, then the current data is moved to the beginning of
54
   the input buffer, and then the remainder of the buffer is loaded with the
51
   the input buffer, and then the remainder of the buffer is loaded with the
55
   available data from the input file. */
52
   available data from the input file. */
56
local int gz_avail(state)
53
local int gz_avail(gz_statep state)
57
    gz_statep state;
58
{
54
{
59
    unsigned got;
55
    unsigned got;
60
    z_streamp strm = &(state->strm);
56
    z_streamp strm = &(state->strm);
Lines 88-95 Link Here
88
   case, all further file reads will be directly to either the output buffer or
84
   case, all further file reads will be directly to either the output buffer or
89
   a user buffer.  If decompressing, the inflate state will be initialized.
85
   a user buffer.  If decompressing, the inflate state will be initialized.
90
   gz_look() will return 0 on success or -1 on failure. */
86
   gz_look() will return 0 on success or -1 on failure. */
91
local int gz_look(state)
87
local int gz_look(gz_statep state)
92
    gz_statep state;
93
{
88
{
94
    z_streamp strm = &(state->strm);
89
    z_streamp strm = &(state->strm);
95
90
Lines 170-177 Link Here
170
   data.  If the gzip stream completes, state->how is reset to LOOK to look for
165
   data.  If the gzip stream completes, state->how is reset to LOOK to look for
171
   the next gzip stream or raw data, once state->x.have is depleted.  Returns 0
166
   the next gzip stream or raw data, once state->x.have is depleted.  Returns 0
172
   on success, -1 on failure. */
167
   on success, -1 on failure. */
173
local int gz_decomp(state)
168
local int gz_decomp(gz_statep state)
174
    gz_statep state;
175
{
169
{
176
    int ret = Z_OK;
170
    int ret = Z_OK;
177
    unsigned had;
171
    unsigned had;
Lines 224-231 Link Here
224
   looked for to determine whether to copy or decompress.  Returns -1 on error,
218
   looked for to determine whether to copy or decompress.  Returns -1 on error,
225
   otherwise 0.  gz_fetch() will leave state->how as COPY or GZIP unless the
219
   otherwise 0.  gz_fetch() will leave state->how as COPY or GZIP unless the
226
   end of the input file has been reached and all data has been processed.  */
220
   end of the input file has been reached and all data has been processed.  */
227
local int gz_fetch(state)
221
local int gz_fetch(gz_statep state)
228
    gz_statep state;
229
{
222
{
230
    z_streamp strm = &(state->strm);
223
    z_streamp strm = &(state->strm);
231
224
Lines 254-262 Link Here
254
}
247
}
255
248
256
/* Skip len uncompressed bytes of output.  Return -1 on error, 0 on success. */
249
/* Skip len uncompressed bytes of output.  Return -1 on error, 0 on success. */
257
local int gz_skip(state, len)
250
local int gz_skip(gz_statep state, z_off64_t len)
258
    gz_statep state;
259
    z_off64_t len;
260
{
251
{
261
    unsigned n;
252
    unsigned n;
262
253
Lines 289-298 Link Here
289
   input.  Return the number of bytes read.  If zero is returned, either the
280
   input.  Return the number of bytes read.  If zero is returned, either the
290
   end of file was reached, or there was an error.  state->err must be
281
   end of file was reached, or there was an error.  state->err must be
291
   consulted in that case to determine which. */
282
   consulted in that case to determine which. */
292
local z_size_t gz_read(state, buf, len)
283
local z_size_t gz_read(gz_statep state, voidp buf, z_size_t len)
293
    gz_statep state;
294
    voidp buf;
295
    z_size_t len;
296
{
284
{
297
    z_size_t got;
285
    z_size_t got;
298
    unsigned n;
286
    unsigned n;
Lines 370-379 Link Here
370
}
358
}
371
359
372
/* -- see zlib.h -- */
360
/* -- see zlib.h -- */
373
int ZEXPORT gzread(file, buf, len)
361
int ZEXPORT gzread(gzFile file, voidp buf, unsigned len)
374
    gzFile file;
375
    voidp buf;
376
    unsigned len;
377
{
362
{
378
    gz_statep state;
363
    gz_statep state;
379
364
Lines 406-416 Link Here
406
}
391
}
407
392
408
/* -- see zlib.h -- */
393
/* -- see zlib.h -- */
409
z_size_t ZEXPORT gzfread(buf, size, nitems, file)
394
z_size_t ZEXPORT gzfread(voidp buf, z_size_t size,
410
    voidp buf;
395
                         z_size_t nitems, gzFile file)
411
    z_size_t size;
412
    z_size_t nitems;
413
    gzFile file;
414
{
396
{
415
    z_size_t len;
397
    z_size_t len;
416
    gz_statep state;
398
    gz_statep state;
Lines 469-484 Link Here
469
    return gz_read(state, buf, 1) < 1 ? -1 : buf[0];
451
    return gz_read(state, buf, 1) < 1 ? -1 : buf[0];
470
}
452
}
471
453
472
int ZEXPORT gzgetc_(file)
454
int ZEXPORT gzgetc_(gzFile file)
473
gzFile file;
474
{
455
{
475
    return gzgetc(file);
456
    return gzgetc(file);
476
}
457
}
477
458
478
/* -- see zlib.h -- */
459
/* -- see zlib.h -- */
479
int ZEXPORT gzungetc(c, file)
460
int ZEXPORT gzungetc(int c, gzFile file)
480
    int c;
481
    gzFile file;
482
{
461
{
483
    gz_statep state;
462
    gz_statep state;
484
463
Lines 536-545 Link Here
536
}
515
}
537
516
538
/* -- see zlib.h -- */
517
/* -- see zlib.h -- */
539
char * ZEXPORT gzgets(file, buf, len)
518
char * ZEXPORT gzgets(gzFile file, char *buf, int len)
540
    gzFile file;
541
    char *buf;
542
    int len;
543
{
519
{
544
    unsigned left, n;
520
    unsigned left, n;
545
    char *str;
521
    char *str;
Lines 600-607 Link Here
600
}
576
}
601
577
602
/* -- see zlib.h -- */
578
/* -- see zlib.h -- */
603
int ZEXPORT gzdirect(file)
579
int ZEXPORT gzdirect(gzFile file)
604
    gzFile file;
605
{
580
{
606
    gz_statep state;
581
    gz_statep state;
607
582
Lines 620-627 Link Here
620
}
595
}
621
596
622
/* -- see zlib.h -- */
597
/* -- see zlib.h -- */
623
int ZEXPORT gzclose_r(file)
598
int ZEXPORT gzclose_r(gzFile file)
624
    gzFile file;
625
{
599
{
626
    int ret, err;
600
    int ret, err;
627
    gz_statep state;
601
    gz_statep state;
(-)a/gzwrite.c (-36 / +12 lines)
Lines 14-21 Link Here
14
/* Initialize state for writing a gzip file.  Mark initialization by setting
14
/* Initialize state for writing a gzip file.  Mark initialization by setting
15
   state->size to non-zero.  Return -1 on a memory allocation failure, or 0 on
15
   state->size to non-zero.  Return -1 on a memory allocation failure, or 0 on
16
   success. */
16
   success. */
17
local int gz_init(state)
17
local int gz_init(gz_statep state)
18
    gz_statep state;
19
{
18
{
20
    int ret;
19
    int ret;
21
    z_streamp strm = &(state->strm);
20
    z_streamp strm = &(state->strm);
Lines 70-78 Link Here
70
   deflate() flush value.  If flush is Z_FINISH, then the deflate() state is
69
   deflate() flush value.  If flush is Z_FINISH, then the deflate() state is
71
   reset to start a new gzip stream.  If gz->direct is true, then simply write
70
   reset to start a new gzip stream.  If gz->direct is true, then simply write
72
   to the output file without compressing, and ignore flush. */
71
   to the output file without compressing, and ignore flush. */
73
local int gz_comp(state, flush)
72
local int gz_comp(gz_statep state, int flush)
74
    gz_statep state;
75
    int flush;
76
{
73
{
77
    int ret, writ;
74
    int ret, writ;
78
    unsigned have, put, max = ((unsigned)-1 >> 2) + 1;
75
    unsigned have, put, max = ((unsigned)-1 >> 2) + 1;
Lines 151-159 Link Here
151
148
152
/* Compress len zeros to output.  Return -1 on a write error or memory
149
/* Compress len zeros to output.  Return -1 on a write error or memory
153
   allocation failure by gz_comp(), or 0 on success. */
150
   allocation failure by gz_comp(), or 0 on success. */
154
local int gz_zero(state, len)
151
local int gz_zero(gz_statep state, z_off64_t len)
155
    gz_statep state;
156
    z_off64_t len;
157
{
152
{
158
    int first;
153
    int first;
159
    unsigned n;
154
    unsigned n;
Lines 184-193 Link Here
184
179
185
/* Write len bytes from buf to file.  Return the number of bytes written.  If
180
/* Write len bytes from buf to file.  Return the number of bytes written.  If
186
   the returned value is less than len, then there was an error. */
181
   the returned value is less than len, then there was an error. */
187
local z_size_t gz_write(state, buf, len)
182
local z_size_t gz_write(gz_statep state, voidpc buf, z_size_t len)
188
    gz_statep state;
189
    voidpc buf;
190
    z_size_t len;
191
{
183
{
192
    z_size_t put = len;
184
    z_size_t put = len;
193
185
Lines 252-261 Link Here
252
}
244
}
253
245
254
/* -- see zlib.h -- */
246
/* -- see zlib.h -- */
255
int ZEXPORT gzwrite(file, buf, len)
247
int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len)
256
    gzFile file;
257
    voidpc buf;
258
    unsigned len;
259
{
248
{
260
    gz_statep state;
249
    gz_statep state;
261
250
Lines 280-290 Link Here
280
}
269
}
281
270
282
/* -- see zlib.h -- */
271
/* -- see zlib.h -- */
283
z_size_t ZEXPORT gzfwrite(buf, size, nitems, file)
272
z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size,
284
    voidpc buf;
273
                          z_size_t nitems, gzFile file)
285
    z_size_t size;
286
    z_size_t nitems;
287
    gzFile file;
288
{
274
{
289
    z_size_t len;
275
    z_size_t len;
290
    gz_statep state;
276
    gz_statep state;
Lines 310-318 Link Here
310
}
296
}
311
297
312
/* -- see zlib.h -- */
298
/* -- see zlib.h -- */
313
int ZEXPORT gzputc(file, c)
299
int ZEXPORT gzputc(gzFile file, int c)
314
    gzFile file;
315
    int c;
316
{
300
{
317
    unsigned have;
301
    unsigned have;
318
    unsigned char buf[1];
302
    unsigned char buf[1];
Lines 358-366 Link Here
358
}
342
}
359
343
360
/* -- see zlib.h -- */
344
/* -- see zlib.h -- */
361
int ZEXPORT gzputs(file, s)
345
int ZEXPORT gzputs(gzFile file, const char *s)
362
    gzFile file;
363
    const char *s;
364
{
346
{
365
    z_size_t len, put;
347
    z_size_t len, put;
366
    gz_statep state;
348
    gz_statep state;
Lines 562-570 Link Here
562
#endif
544
#endif
563
545
564
/* -- see zlib.h -- */
546
/* -- see zlib.h -- */
565
int ZEXPORT gzflush(file, flush)
547
int ZEXPORT gzflush(gzFile file, int flush)
566
    gzFile file;
567
    int flush;
568
{
548
{
569
    gz_statep state;
549
    gz_statep state;
570
550
Lines 594-603 Link Here
594
}
574
}
595
575
596
/* -- see zlib.h -- */
576
/* -- see zlib.h -- */
597
int ZEXPORT gzsetparams(file, level, strategy)
577
int ZEXPORT gzsetparams(gzFile file, int level, int strategy)
598
    gzFile file;
599
    int level;
600
    int strategy;
601
{
578
{
602
    gz_statep state;
579
    gz_statep state;
603
    z_streamp strm;
580
    z_streamp strm;
Lines 636-643 Link Here
636
}
613
}
637
614
638
/* -- see zlib.h -- */
615
/* -- see zlib.h -- */
639
int ZEXPORT gzclose_w(file)
616
int ZEXPORT gzclose_w(gzFile file)
640
    gzFile file;
641
{
617
{
642
    int ret = Z_OK;
618
    int ret = Z_OK;
643
    gz_statep state;
619
    gz_statep state;
(-)a/infback.c (-16 / +7 lines)
Lines 25-36 Link Here
25
   windowBits is in the range 8..15, and window is a user-supplied
25
   windowBits is in the range 8..15, and window is a user-supplied
26
   window and output buffer that is 2**windowBits bytes.
26
   window and output buffer that is 2**windowBits bytes.
27
 */
27
 */
28
int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size)
28
int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits,
29
z_streamp strm;
29
                             unsigned char FAR *window,
30
int windowBits;
30
                             const char *version, int stream_size)
31
unsigned char FAR *window;
32
const char *version;
33
int stream_size;
34
{
31
{
35
    struct inflate_state FAR *state;
32
    struct inflate_state FAR *state;
36
33
Lines 80-87 Link Here
80
   used for threaded applications, since the rewriting of the tables and virgin
77
   used for threaded applications, since the rewriting of the tables and virgin
81
   may not be thread-safe.
78
   may not be thread-safe.
82
 */
79
 */
83
local void fixedtables(state)
80
local void fixedtables(struct inflate_state FAR *state)
84
struct inflate_state FAR *state;
85
{
81
{
86
#ifdef BUILDFIXED
82
#ifdef BUILDFIXED
87
    static int virgin = 1;
83
    static int virgin = 1;
Lines 248-259 Link Here
248
   inflateBack() can also return Z_STREAM_ERROR if the input parameters
244
   inflateBack() can also return Z_STREAM_ERROR if the input parameters
249
   are not correct, i.e. strm is Z_NULL or the state was not initialized.
245
   are not correct, i.e. strm is Z_NULL or the state was not initialized.
250
 */
246
 */
251
int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc)
247
int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
252
z_streamp strm;
248
                        out_func out, void FAR *out_desc)
253
in_func in;
254
void FAR *in_desc;
255
out_func out;
256
void FAR *out_desc;
257
{
249
{
258
    struct inflate_state FAR *state;
250
    struct inflate_state FAR *state;
259
    z_const unsigned char FAR *next;    /* next input */
251
    z_const unsigned char FAR *next;    /* next input */
Lines 632-639 Link Here
632
    return ret;
624
    return ret;
633
}
625
}
634
626
635
int ZEXPORT inflateBackEnd(strm)
627
int ZEXPORT inflateBackEnd(z_streamp strm)
636
z_streamp strm;
637
{
628
{
638
    if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
629
    if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
639
        return Z_STREAM_ERROR;
630
        return Z_STREAM_ERROR;
(-)a/inffast.c (-3 / +2 lines)
Lines 47-55 Link Here
47
      requires strm->avail_out >= 258 for each loop to avoid checking for
47
      requires strm->avail_out >= 258 for each loop to avoid checking for
48
      output space.
48
      output space.
49
 */
49
 */
50
void ZLIB_INTERNAL inflate_fast(strm, start)
50
void ZLIB_INTERNAL inflate_fast(z_streamp strm,
51
z_streamp strm;
51
        unsigned start /* inflate()'s starting value for strm->avail_out */)
52
unsigned start;         /* inflate()'s starting value for strm->avail_out */
53
{
52
{
54
    struct inflate_state FAR *state;
53
    struct inflate_state FAR *state;
55
    z_const unsigned char FAR *in;      /* local strm->next_in */
54
    z_const unsigned char FAR *in;      /* local strm->next_in */
(-)a/inflate.c (-65 / +26 lines)
Lines 102-109 Link Here
102
local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf,
102
local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf,
103
                              unsigned len));
103
                              unsigned len));
104
104
105
local int inflateStateCheck(strm)
105
local int inflateStateCheck(z_streamp strm)
106
z_streamp strm;
107
{
106
{
108
    struct inflate_state FAR *state;
107
    struct inflate_state FAR *state;
109
    if (strm == Z_NULL ||
108
    if (strm == Z_NULL ||
Lines 116-123 Link Here
116
    return 0;
115
    return 0;
117
}
116
}
118
117
119
int ZEXPORT inflateResetKeep(strm)
118
int ZEXPORT inflateResetKeep(z_streamp strm)
120
z_streamp strm;
121
{
119
{
122
    struct inflate_state FAR *state;
120
    struct inflate_state FAR *state;
123
121
Lines 142-149 Link Here
142
    return Z_OK;
140
    return Z_OK;
143
}
141
}
144
142
145
int ZEXPORT inflateReset(strm)
143
int ZEXPORT inflateReset(z_streamp strm)
146
z_streamp strm;
147
{
144
{
148
    struct inflate_state FAR *state;
145
    struct inflate_state FAR *state;
149
146
Lines 155-163 Link Here
155
    return inflateResetKeep(strm);
152
    return inflateResetKeep(strm);
156
}
153
}
157
154
158
int ZEXPORT inflateReset2(strm, windowBits)
155
int ZEXPORT inflateReset2(z_streamp strm, int windowBits)
159
z_streamp strm;
160
int windowBits;
161
{
156
{
162
    int wrap;
157
    int wrap;
163
    struct inflate_state FAR *state;
158
    struct inflate_state FAR *state;
Lines 195-205 Link Here
195
    return inflateReset(strm);
190
    return inflateReset(strm);
196
}
191
}
197
192
198
int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size)
193
int ZEXPORT inflateInit2_(z_streamp strm, int windowBits,
199
z_streamp strm;
194
                          const char * version, int stream_size)
200
int windowBits;
201
const char *version;
202
int stream_size;
203
{
195
{
204
    int ret;
196
    int ret;
205
    struct inflate_state FAR *state;
197
    struct inflate_state FAR *state;
Lines 239-256 Link Here
239
    return ret;
231
    return ret;
240
}
232
}
241
233
242
int ZEXPORT inflateInit_(strm, version, stream_size)
234
int ZEXPORT inflateInit_(z_streamp strm, const char *version, int stream_size)
243
z_streamp strm;
244
const char *version;
245
int stream_size;
246
{
235
{
247
    return inflateInit2_(strm, DEF_WBITS, version, stream_size);
236
    return inflateInit2_(strm, DEF_WBITS, version, stream_size);
248
}
237
}
249
238
250
int ZEXPORT inflatePrime(strm, bits, value)
239
int ZEXPORT inflatePrime(z_streamp strm, int bits, int value)
251
z_streamp strm;
252
int bits;
253
int value;
254
{
240
{
255
    struct inflate_state FAR *state;
241
    struct inflate_state FAR *state;
256
242
Lines 278-285 Link Here
278
   used for threaded applications, since the rewriting of the tables and virgin
264
   used for threaded applications, since the rewriting of the tables and virgin
279
   may not be thread-safe.
265
   may not be thread-safe.
280
 */
266
 */
281
local void fixedtables(state)
267
local void fixedtables(struct inflate_state FAR *state)
282
struct inflate_state FAR *state;
283
{
268
{
284
#ifdef BUILDFIXED
269
#ifdef BUILDFIXED
285
    static int virgin = 1;
270
    static int virgin = 1;
Lines 396-405 Link Here
396
   output will fall in the output data, making match copies simpler and faster.
381
   output will fall in the output data, making match copies simpler and faster.
397
   The advantage may be dependent on the size of the processor's data caches.
382
   The advantage may be dependent on the size of the processor's data caches.
398
 */
383
 */
399
local int updatewindow(strm, end, copy)
384
local int updatewindow(z_streamp strm, const Bytef *end, unsigned copy)
400
z_streamp strm;
401
const Bytef *end;
402
unsigned copy;
403
{
385
{
404
    struct inflate_state FAR *state;
386
    struct inflate_state FAR *state;
405
    unsigned dist;
387
    unsigned dist;
Lines 622-630 Link Here
622
   will return Z_BUF_ERROR if it has not reached the end of the stream.
604
   will return Z_BUF_ERROR if it has not reached the end of the stream.
623
 */
605
 */
624
606
625
int ZEXPORT inflate(strm, flush)
607
int ZEXPORT inflate(z_streamp strm, int flush)
626
z_streamp strm;
627
int flush;
628
{
608
{
629
    struct inflate_state FAR *state;
609
    struct inflate_state FAR *state;
630
    z_const unsigned char FAR *next;    /* next input */
610
    z_const unsigned char FAR *next;    /* next input */
Lines 1301-1308 Link Here
1301
    return ret;
1281
    return ret;
1302
}
1282
}
1303
1283
1304
int ZEXPORT inflateEnd(strm)
1284
int ZEXPORT inflateEnd(z_streamp strm)
1305
z_streamp strm;
1306
{
1285
{
1307
    struct inflate_state FAR *state;
1286
    struct inflate_state FAR *state;
1308
    if (inflateStateCheck(strm))
1287
    if (inflateStateCheck(strm))
Lines 1315-1324 Link Here
1315
    return Z_OK;
1294
    return Z_OK;
1316
}
1295
}
1317
1296
1318
int ZEXPORT inflateGetDictionary(strm, dictionary, dictLength)
1297
int ZEXPORT inflateGetDictionary(z_streamp strm, Bytef *dictionary,
1319
z_streamp strm;
1298
                                 uInt *dictLength)
1320
Bytef *dictionary;
1321
uInt *dictLength;
1322
{
1299
{
1323
    struct inflate_state FAR *state;
1300
    struct inflate_state FAR *state;
1324
1301
Lines 1338-1347 Link Here
1338
    return Z_OK;
1315
    return Z_OK;
1339
}
1316
}
1340
1317
1341
int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength)
1318
int ZEXPORT inflateSetDictionary(z_streamp strm, const Bytef *dictionary,
1342
z_streamp strm;
1319
                                 uInt dictLength)
1343
const Bytef *dictionary;
1344
uInt dictLength;
1345
{
1320
{
1346
    struct inflate_state FAR *state;
1321
    struct inflate_state FAR *state;
1347
    unsigned long dictid;
1322
    unsigned long dictid;
Lines 1373-1381 Link Here
1373
    return Z_OK;
1348
    return Z_OK;
1374
}
1349
}
1375
1350
1376
int ZEXPORT inflateGetHeader(strm, head)
1351
int ZEXPORT inflateGetHeader(z_streamp strm, gz_headerp head)
1377
z_streamp strm;
1378
gz_headerp head;
1379
{
1352
{
1380
    struct inflate_state FAR *state;
1353
    struct inflate_state FAR *state;
1381
1354
Lines 1401-1410 Link Here
1401
   called again with more data and the *have state.  *have is initialized to
1374
   called again with more data and the *have state.  *have is initialized to
1402
   zero for the first call.
1375
   zero for the first call.
1403
 */
1376
 */
1404
local unsigned syncsearch(have, buf, len)
1377
local unsigned syncsearch(unsigned FAR *have,
1405
unsigned FAR *have;
1378
                          const unsigned char FAR *buf, unsigned len)
1406
const unsigned char FAR *buf;
1407
unsigned len;
1408
{
1379
{
1409
    unsigned got;
1380
    unsigned got;
1410
    unsigned next;
1381
    unsigned next;
Lines 1424-1431 Link Here
1424
    return next;
1395
    return next;
1425
}
1396
}
1426
1397
1427
int ZEXPORT inflateSync(strm)
1398
int ZEXPORT inflateSync(z_streamp strm)
1428
z_streamp strm;
1429
{
1399
{
1430
    unsigned len;               /* number of bytes to look at or looked at */
1400
    unsigned len;               /* number of bytes to look at or looked at */
1431
    int flags;                  /* temporary to save header status */
1401
    int flags;                  /* temporary to save header status */
Lines 1482-1489 Link Here
1482
   block. When decompressing, PPP checks that at the end of input packet,
1452
   block. When decompressing, PPP checks that at the end of input packet,
1483
   inflate is waiting for these length bytes.
1453
   inflate is waiting for these length bytes.
1484
 */
1454
 */
1485
int ZEXPORT inflateSyncPoint(strm)
1455
int ZEXPORT inflateSyncPoint(z_streamp strm)
1486
z_streamp strm;
1487
{
1456
{
1488
    struct inflate_state FAR *state;
1457
    struct inflate_state FAR *state;
1489
1458
Lines 1492-1500 Link Here
1492
    return state->mode == STORED && state->bits == 0;
1461
    return state->mode == STORED && state->bits == 0;
1493
}
1462
}
1494
1463
1495
int ZEXPORT inflateCopy(dest, source)
1464
int ZEXPORT inflateCopy(z_streamp dest, z_streamp source)
1496
z_streamp dest;
1497
z_streamp source;
1498
{
1465
{
1499
    struct inflate_state FAR *state;
1466
    struct inflate_state FAR *state;
1500
    struct inflate_state FAR *copy;
1467
    struct inflate_state FAR *copy;
Lines 1539-1547 Link Here
1539
    return Z_OK;
1506
    return Z_OK;
1540
}
1507
}
1541
1508
1542
int ZEXPORT inflateUndermine(strm, subvert)
1509
int ZEXPORT inflateUndermine(z_streamp strm, int subvert)
1543
z_streamp strm;
1544
int subvert;
1545
{
1510
{
1546
    struct inflate_state FAR *state;
1511
    struct inflate_state FAR *state;
1547
1512
Lines 1557-1565 Link Here
1557
#endif
1522
#endif
1558
}
1523
}
1559
1524
1560
int ZEXPORT inflateValidate(strm, check)
1525
int ZEXPORT inflateValidate(z_streamp strm, int check)
1561
z_streamp strm;
1562
int check;
1563
{
1526
{
1564
    struct inflate_state FAR *state;
1527
    struct inflate_state FAR *state;
1565
1528
Lines 1572-1579 Link Here
1572
    return Z_OK;
1535
    return Z_OK;
1573
}
1536
}
1574
1537
1575
long ZEXPORT inflateMark(strm)
1538
long ZEXPORT inflateMark(z_streamp strm)
1576
z_streamp strm;
1577
{
1539
{
1578
    struct inflate_state FAR *state;
1540
    struct inflate_state FAR *state;
1579
1541
Lines 1585-1592 Link Here
1585
            (state->mode == MATCH ? state->was - state->length : 0));
1547
            (state->mode == MATCH ? state->was - state->length : 0));
1586
}
1548
}
1587
1549
1588
unsigned long ZEXPORT inflateCodesUsed(strm)
1550
unsigned long ZEXPORT inflateCodesUsed(z_streamp strm)
1589
z_streamp strm;
1590
{
1551
{
1591
    struct inflate_state FAR *state;
1552
    struct inflate_state FAR *state;
1592
    if (inflateStateCheck(strm)) return (unsigned long)-1;
1553
    if (inflateStateCheck(strm)) return (unsigned long)-1;
(-)a/inftrees.c (-7 / +3 lines)
Lines 29-41 Link Here
29
   table index bits.  It will differ if the request is greater than the
29
   table index bits.  It will differ if the request is greater than the
30
   longest code or if it is less than the shortest code.
30
   longest code or if it is less than the shortest code.
31
 */
31
 */
32
int ZLIB_INTERNAL inflate_table(type, lens, codes, table, bits, work)
32
int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
33
codetype type;
33
                                unsigned codes, code FAR * FAR *table,
34
unsigned short FAR *lens;
34
                                unsigned FAR *bits, unsigned short FAR *work)
35
unsigned codes;
36
code FAR * FAR *table;
37
unsigned FAR *bits;
38
unsigned short FAR *work;
39
{
35
{
40
    unsigned len;               /* a code's length in bits */
36
    unsigned len;               /* a code's length in bits */
41
    unsigned sym;               /* index of code symbols */
37
    unsigned sym;               /* index of code symbols */
(-)a/test/example.c (-37 / +13 lines)
Lines 55-63 Link Here
55
void *myalloc OF((void *, unsigned, unsigned));
55
void *myalloc OF((void *, unsigned, unsigned));
56
void myfree OF((void *, void *));
56
void myfree OF((void *, void *));
57
57
58
void *myalloc(q, n, m)
58
void *myalloc(void *q, unsigned n, unsigned m)
59
    void *q;
60
    unsigned n, m;
61
{
59
{
62
    (void)q;
60
    (void)q;
63
    return calloc(n, m);
61
    return calloc(n, m);
Lines 85-93 Link Here
85
/* ===========================================================================
83
/* ===========================================================================
86
 * Test compress() and uncompress()
84
 * Test compress() and uncompress()
87
 */
85
 */
88
void test_compress(compr, comprLen, uncompr, uncomprLen)
86
void test_compress(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)
89
    Byte *compr, *uncompr;
90
    uLong comprLen, uncomprLen;
91
{
87
{
92
    int err;
88
    int err;
93
    uLong len = (uLong)strlen(hello)+1;
89
    uLong len = (uLong)strlen(hello)+1;
Lines 111-120 Link Here
111
/* ===========================================================================
107
/* ===========================================================================
112
 * Test read/write of .gz files
108
 * Test read/write of .gz files
113
 */
109
 */
114
void test_gzio(fname, uncompr, uncomprLen)
110
void test_gzio(const char *fname /* compressed file name */,
115
    const char *fname; /* compressed file name */
111
               Byte *uncompr, uLong uncomprLen)
116
    Byte *uncompr;
117
    uLong uncomprLen;
118
{
112
{
119
#ifdef NO_GZCOMPRESS
113
#ifdef NO_GZCOMPRESS
120
    fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n");
114
    fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n");
Lines 197-205 Link Here
197
/* ===========================================================================
191
/* ===========================================================================
198
 * Test deflate() with small buffers
192
 * Test deflate() with small buffers
199
 */
193
 */
200
void test_deflate(compr, comprLen)
194
void test_deflate(Byte *compr, uLong comprLen)
201
    Byte *compr;
202
    uLong comprLen;
203
{
195
{
204
    z_stream c_stream; /* compression stream */
196
    z_stream c_stream; /* compression stream */
205
    int err;
197
    int err;
Lines 235-243 Link Here
235
/* ===========================================================================
227
/* ===========================================================================
236
 * Test inflate() with small buffers
228
 * Test inflate() with small buffers
237
 */
229
 */
238
void test_inflate(compr, comprLen, uncompr, uncomprLen)
230
void test_inflate(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)
239
    Byte *compr, *uncompr;
240
    uLong comprLen, uncomprLen;
241
{
231
{
242
    int err;
232
    int err;
243
    z_stream d_stream; /* decompression stream */
233
    z_stream d_stream; /* decompression stream */
Lines 276-284 Link Here
276
/* ===========================================================================
266
/* ===========================================================================
277
 * Test deflate() with large buffers and dynamic change of compression level
267
 * Test deflate() with large buffers and dynamic change of compression level
278
 */
268
 */
279
void test_large_deflate(compr, comprLen, uncompr, uncomprLen)
269
void test_large_deflate(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)
280
    Byte *compr, *uncompr;
281
    uLong comprLen, uncomprLen;
282
{
270
{
283
    z_stream c_stream; /* compression stream */
271
    z_stream c_stream; /* compression stream */
284
    int err;
272
    int err;
Lines 331-339 Link Here
331
/* ===========================================================================
319
/* ===========================================================================
332
 * Test inflate() with large buffers
320
 * Test inflate() with large buffers
333
 */
321
 */
334
void test_large_inflate(compr, comprLen, uncompr, uncomprLen)
322
void test_large_inflate(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)
335
    Byte *compr, *uncompr;
336
    uLong comprLen, uncomprLen;
337
{
323
{
338
    int err;
324
    int err;
339
    z_stream d_stream; /* decompression stream */
325
    z_stream d_stream; /* decompression stream */
Lines 372-380 Link Here
372
/* ===========================================================================
358
/* ===========================================================================
373
 * Test deflate() with full flush
359
 * Test deflate() with full flush
374
 */
360
 */
375
void test_flush(compr, comprLen)
361
void test_flush(Byte *compr, uLong *comprLen)
376
    Byte *compr;
377
    uLong *comprLen;
378
{
362
{
379
    z_stream c_stream; /* compression stream */
363
    z_stream c_stream; /* compression stream */
380
    int err;
364
    int err;
Lines 410-418 Link Here
410
/* ===========================================================================
394
/* ===========================================================================
411
 * Test inflateSync()
395
 * Test inflateSync()
412
 */
396
 */
413
void test_sync(compr, comprLen, uncompr, uncomprLen)
397
void test_sync(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)
414
    Byte *compr, *uncompr;
415
    uLong comprLen, uncomprLen;
416
{
398
{
417
    int err;
399
    int err;
418
    z_stream d_stream; /* decompression stream */
400
    z_stream d_stream; /* decompression stream */
Lines 453-461 Link Here
453
/* ===========================================================================
435
/* ===========================================================================
454
 * Test deflate() with preset dictionary
436
 * Test deflate() with preset dictionary
455
 */
437
 */
456
void test_dict_deflate(compr, comprLen)
438
void test_dict_deflate(Byte *compr, uLong comprLen)
457
    Byte *compr;
458
    uLong comprLen;
459
{
439
{
460
    z_stream c_stream; /* compression stream */
440
    z_stream c_stream; /* compression stream */
461
    int err;
441
    int err;
Lines 490-498 Link Here
490
/* ===========================================================================
470
/* ===========================================================================
491
 * Test inflate() with a preset dictionary
471
 * Test inflate() with a preset dictionary
492
 */
472
 */
493
void test_dict_inflate(compr, comprLen, uncompr, uncomprLen)
473
void test_dict_inflate(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)
494
    Byte *compr, *uncompr;
495
    uLong comprLen, uncomprLen;
496
{
474
{
497
    int err;
475
    int err;
498
    z_stream d_stream; /* decompression stream */
476
    z_stream d_stream; /* decompression stream */
Lines 541-549 Link Here
541
 * Usage:  example [output.gz  [input.gz]]
519
 * Usage:  example [output.gz  [input.gz]]
542
 */
520
 */
543
521
544
int main(argc, argv)
522
int main(int argc, char *argv[])
545
    int argc;
546
    char *argv[];
547
{
523
{
548
    Byte *compr, *uncompr;
524
    Byte *compr, *uncompr;
549
    uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */
525
    uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */
(-)a/trees.c (-66 / +45 lines)
Lines 183-192 Link Here
183
#ifdef ZLIB_DEBUG
183
#ifdef ZLIB_DEBUG
184
local void send_bits      OF((deflate_state *s, int value, int length));
184
local void send_bits      OF((deflate_state *s, int value, int length));
185
185
186
local void send_bits(s, value, length)
186
local void send_bits(deflate_state *s,
187
    deflate_state *s;
187
                     int value /* value to send */,
188
    int value;  /* value to send */
188
                     int length /* number of bits */)
189
    int length; /* number of bits */
190
{
189
{
191
    Tracevv((stderr," l %2d v %4x ", length, value));
190
    Tracevv((stderr," l %2d v %4x ", length, value));
192
    Assert(length > 0 && length <= 15, "invalid length");
191
    Assert(length > 0 && length <= 15, "invalid length");
Lines 376-383 Link Here
376
/* ===========================================================================
375
/* ===========================================================================
377
 * Initialize the tree data structures for a new zlib stream.
376
 * Initialize the tree data structures for a new zlib stream.
378
 */
377
 */
379
void ZLIB_INTERNAL _tr_init(s)
378
void ZLIB_INTERNAL _tr_init(deflate_state *s)
380
    deflate_state *s;
381
{
379
{
382
    tr_static_init();
380
    tr_static_init();
383
381
Lines 404-411 Link Here
404
/* ===========================================================================
402
/* ===========================================================================
405
 * Initialize a new block.
403
 * Initialize a new block.
406
 */
404
 */
407
local void init_block(s)
405
local void init_block(deflate_state *s)
408
    deflate_state *s;
409
{
406
{
410
    int n; /* iterates over tree elements */
407
    int n; /* iterates over tree elements */
411
408
Lines 448-457 Link Here
448
 * when the heap property is re-established (each father smaller than its
445
 * when the heap property is re-established (each father smaller than its
449
 * two sons).
446
 * two sons).
450
 */
447
 */
451
local void pqdownheap(s, tree, k)
448
local void pqdownheap(deflate_state *s,
452
    deflate_state *s;
449
                      ct_data *tree /* the tree to restore */,
453
    ct_data *tree;  /* the tree to restore */
450
                      int k /* node to move down */)
454
    int k;               /* node to move down */
455
{
451
{
456
    int v = s->heap[k];
452
    int v = s->heap[k];
457
    int j = k << 1;  /* left son of k */
453
    int j = k << 1;  /* left son of k */
Lines 483-491 Link Here
483
 *     The length opt_len is updated; static_len is also updated if stree is
479
 *     The length opt_len is updated; static_len is also updated if stree is
484
 *     not null.
480
 *     not null.
485
 */
481
 */
486
local void gen_bitlen(s, desc)
482
local void gen_bitlen(deflate_state *s,
487
    deflate_state *s;
483
                      tree_desc *desc /* the tree descriptor */)
488
    tree_desc *desc;    /* the tree descriptor */
489
{
484
{
490
    ct_data *tree        = desc->dyn_tree;
485
    ct_data *tree        = desc->dyn_tree;
491
    int max_code         = desc->max_code;
486
    int max_code         = desc->max_code;
Lines 569-578 Link Here
569
 * OUT assertion: the field code is set for all tree elements of non
564
 * OUT assertion: the field code is set for all tree elements of non
570
 *     zero code length.
565
 *     zero code length.
571
 */
566
 */
572
local void gen_codes(tree, max_code, bl_count)
567
local void gen_codes(ct_data *tree /* the tree to decorate */,
573
    ct_data *tree;             /* the tree to decorate */
568
                     int max_code /* largest code with non zero frequency */,
574
    int max_code;              /* largest code with non zero frequency */
569
                     ushf *bl_count /* number of codes at each bit length */)
575
    ushf *bl_count;            /* number of codes at each bit length */
576
{
570
{
577
    ush next_code[MAX_BITS+1]; /* next code value for each bit length */
571
    ush next_code[MAX_BITS+1]; /* next code value for each bit length */
578
    unsigned code = 0;         /* running code value */
572
    unsigned code = 0;         /* running code value */
Lines 612-620 Link Here
612
 *     and corresponding code. The length opt_len is updated; static_len is
606
 *     and corresponding code. The length opt_len is updated; static_len is
613
 *     also updated if stree is not null. The field max_code is set.
607
 *     also updated if stree is not null. The field max_code is set.
614
 */
608
 */
615
local void build_tree(s, desc)
609
local void build_tree(deflate_state *s,
616
    deflate_state *s;
610
                      tree_desc *desc /* the tree descriptor */)
617
    tree_desc *desc; /* the tree descriptor */
618
{
611
{
619
    ct_data *tree         = desc->dyn_tree;
612
    ct_data *tree         = desc->dyn_tree;
620
    const ct_data *stree  = desc->stat_desc->static_tree;
613
    const ct_data *stree  = desc->stat_desc->static_tree;
Lines 700-709 Link Here
700
 * Scan a literal or distance tree to determine the frequencies of the codes
693
 * Scan a literal or distance tree to determine the frequencies of the codes
701
 * in the bit length tree.
694
 * in the bit length tree.
702
 */
695
 */
703
local void scan_tree(s, tree, max_code)
696
local void scan_tree(deflate_state *s,
704
    deflate_state *s;
697
                     ct_data *tree /* the tree to be scanned */,
705
    ct_data *tree;   /* the tree to be scanned */
698
                     int max_code /* and its largest code of non zero frequency */)
706
    int max_code;    /* and its largest code of non zero frequency */
707
{
699
{
708
    int n;                     /* iterates over all tree elements */
700
    int n;                     /* iterates over all tree elements */
709
    int prevlen = -1;          /* last emitted length */
701
    int prevlen = -1;          /* last emitted length */
Lines 745-754 Link Here
745
 * Send a literal or distance tree in compressed form, using the codes in
737
 * Send a literal or distance tree in compressed form, using the codes in
746
 * bl_tree.
738
 * bl_tree.
747
 */
739
 */
748
local void send_tree(s, tree, max_code)
740
local void send_tree( deflate_state *s,
749
    deflate_state *s;
741
                      ct_data *tree /* the tree to be scanned */,
750
    ct_data *tree; /* the tree to be scanned */
742
                      int max_code /* and its largest code of non zero frequency */)
751
    int max_code;       /* and its largest code of non zero frequency */
752
{
743
{
753
    int n;                     /* iterates over all tree elements */
744
    int n;                     /* iterates over all tree elements */
754
    int prevlen = -1;          /* last emitted length */
745
    int prevlen = -1;          /* last emitted length */
Lines 796-803 Link Here
796
 * Construct the Huffman tree for the bit lengths and return the index in
787
 * Construct the Huffman tree for the bit lengths and return the index in
797
 * bl_order of the last bit length code to send.
788
 * bl_order of the last bit length code to send.
798
 */
789
 */
799
local int build_bl_tree(s)
790
local int build_bl_tree(deflate_state *s)
800
    deflate_state *s;
801
{
791
{
802
    int max_blindex;  /* index of last bit length code of non zero freq */
792
    int max_blindex;  /* index of last bit length code of non zero freq */
803
793
Lines 831-839 Link Here
831
 * lengths of the bit length codes, the literal tree and the distance tree.
821
 * lengths of the bit length codes, the literal tree and the distance tree.
832
 * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
822
 * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
833
 */
823
 */
834
local void send_all_trees(s, lcodes, dcodes, blcodes)
824
local void send_all_trees(deflate_state *s,
835
    deflate_state *s;
825
    /* number of codes for each tree */ int lcodes, int dcodes, int blcodes)
836
    int lcodes, dcodes, blcodes; /* number of codes for each tree */
837
{
826
{
838
    int rank;                    /* index in bl_order */
827
    int rank;                    /* index in bl_order */
839
828
Lines 860-870 Link Here
860
/* ===========================================================================
849
/* ===========================================================================
861
 * Send a stored block
850
 * Send a stored block
862
 */
851
 */
863
void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last)
852
void ZLIB_INTERNAL _tr_stored_block(deflate_state *s,
864
    deflate_state *s;
853
                                    charf *buf /* input block */,
865
    charf *buf;       /* input block */
854
                                    ulg stored_len /* length of input block */,
866
    ulg stored_len;   /* length of input block */
855
                                    int last /* one if this is the last block for a file */)
867
    int last;         /* one if this is the last block for a file */
868
{
856
{
869
    send_bits(s, (STORED_BLOCK<<1) + last, 3);  /* send block type */
857
    send_bits(s, (STORED_BLOCK<<1) + last, 3);  /* send block type */
870
    bi_windup(s);        /* align on byte boundary */
858
    bi_windup(s);        /* align on byte boundary */
Lines 884-891 Link Here
884
/* ===========================================================================
872
/* ===========================================================================
885
 * Flush the bits in the bit buffer to pending output (leaves at most 7 bits)
873
 * Flush the bits in the bit buffer to pending output (leaves at most 7 bits)
886
 */
874
 */
887
void ZLIB_INTERNAL _tr_flush_bits(s)
875
void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s)
888
    deflate_state *s;
889
{
876
{
890
    bi_flush(s);
877
    bi_flush(s);
891
}
878
}
Lines 894-901 Link Here
894
 * Send one empty static block to give enough lookahead for inflate.
881
 * Send one empty static block to give enough lookahead for inflate.
895
 * This takes 10 bits, of which 7 may remain in the bit buffer.
882
 * This takes 10 bits, of which 7 may remain in the bit buffer.
896
 */
883
 */
897
void ZLIB_INTERNAL _tr_align(s)
884
void ZLIB_INTERNAL _tr_align(deflate_state *s)
898
    deflate_state *s;
899
{
885
{
900
    send_bits(s, STATIC_TREES<<1, 3);
886
    send_bits(s, STATIC_TREES<<1, 3);
901
    send_code(s, END_BLOCK, static_ltree);
887
    send_code(s, END_BLOCK, static_ltree);
Lines 909-919 Link Here
909
 * Determine the best encoding for the current block: dynamic trees, static
895
 * Determine the best encoding for the current block: dynamic trees, static
910
 * trees or store, and write out the encoded block.
896
 * trees or store, and write out the encoded block.
911
 */
897
 */
912
void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
898
void ZLIB_INTERNAL _tr_flush_block(deflate_state *s,
913
    deflate_state *s;
899
                                   charf *buf /* input block, or NULL if too old */,
914
    charf *buf;       /* input block, or NULL if too old */
900
                                   ulg stored_len /* length of input block */,
915
    ulg stored_len;   /* length of input block */
901
                                   int last /* one if this is the last block for a file */)
916
    int last;         /* one if this is the last block for a file */
917
{
902
{
918
    ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */
903
    ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */
919
    int max_blindex = 0;  /* index of last bit length code of non zero freq */
904
    int max_blindex = 0;  /* index of last bit length code of non zero freq */
Lines 1011-1020 Link Here
1011
 * Save the match info and tally the frequency counts. Return true if
996
 * Save the match info and tally the frequency counts. Return true if
1012
 * the current block must be flushed.
997
 * the current block must be flushed.
1013
 */
998
 */
1014
int ZLIB_INTERNAL _tr_tally(s, dist, lc)
999
int ZLIB_INTERNAL _tr_tally(deflate_state *s,
1015
    deflate_state *s;
1000
        unsigned dist /* distance of matched string */,
1016
    unsigned dist;  /* distance of matched string */
1001
        unsigned lc /* match length - MIN_MATCH or unmatched char (dist==0) */)
1017
    unsigned lc;    /* match length - MIN_MATCH or unmatched char (dist==0) */
1018
{
1002
{
1019
    s->sym_buf[s->sym_next++] = (uch)dist;
1003
    s->sym_buf[s->sym_next++] = (uch)dist;
1020
    s->sym_buf[s->sym_next++] = (uch)(dist >> 8);
1004
    s->sym_buf[s->sym_next++] = (uch)(dist >> 8);
Lines 1039-1048 Link Here
1039
/* ===========================================================================
1023
/* ===========================================================================
1040
 * Send the block data compressed using the given Huffman trees
1024
 * Send the block data compressed using the given Huffman trees
1041
 */
1025
 */
1042
local void compress_block(s, ltree, dtree)
1026
local void compress_block(deflate_state *s,
1043
    deflate_state *s;
1027
                          const ct_data *ltree /* literal tree */,
1044
    const ct_data *ltree; /* literal tree */
1028
                          const ct_data *dtree /* distance tree */)
1045
    const ct_data *dtree; /* distance tree */
1046
{
1029
{
1047
    unsigned dist;      /* distance of matched string */
1030
    unsigned dist;      /* distance of matched string */
1048
    int lc;             /* match length or unmatched char (if dist == 0) */
1031
    int lc;             /* match length or unmatched char (if dist == 0) */
Lines 1099-1106 Link Here
1099
 *   (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).
1082
 *   (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).
1100
 * IN assertion: the fields Freq of dyn_ltree are set.
1083
 * IN assertion: the fields Freq of dyn_ltree are set.
1101
 */
1084
 */
1102
local int detect_data_type(s)
1085
local int detect_data_type(deflate_state *s)
1103
    deflate_state *s;
1104
{
1086
{
1105
    /* block_mask is the bit mask of block-listed bytes
1087
    /* block_mask is the bit mask of block-listed bytes
1106
     * set bits 0..6, 14..25, and 28..31
1088
     * set bits 0..6, 14..25, and 28..31
Lines 1133-1141 Link Here
1133
 * method would use a table)
1115
 * method would use a table)
1134
 * IN assertion: 1 <= len <= 15
1116
 * IN assertion: 1 <= len <= 15
1135
 */
1117
 */
1136
local unsigned bi_reverse(code, len)
1118
local unsigned bi_reverse(unsigned code /* the value to invert */,
1137
    unsigned code; /* the value to invert */
1119
                          int len /* its bit length */)
1138
    int len;       /* its bit length */
1139
{
1120
{
1140
    register unsigned res = 0;
1121
    register unsigned res = 0;
1141
    do {
1122
    do {
Lines 1148-1155 Link Here
1148
/* ===========================================================================
1129
/* ===========================================================================
1149
 * Flush the bit buffer, keeping at most 7 bits in it.
1130
 * Flush the bit buffer, keeping at most 7 bits in it.
1150
 */
1131
 */
1151
local void bi_flush(s)
1132
local void bi_flush(deflate_state *s)
1152
    deflate_state *s;
1153
{
1133
{
1154
    if (s->bi_valid == 16) {
1134
    if (s->bi_valid == 16) {
1155
        put_short(s, s->bi_buf);
1135
        put_short(s, s->bi_buf);
Lines 1165-1172 Link Here
1165
/* ===========================================================================
1145
/* ===========================================================================
1166
 * Flush the bit buffer and align the output on a byte boundary
1146
 * Flush the bit buffer and align the output on a byte boundary
1167
 */
1147
 */
1168
local void bi_windup(s)
1148
local void bi_windup(deflate_state *s)
1169
    deflate_state *s;
1170
{
1149
{
1171
    if (s->bi_valid > 8) {
1150
    if (s->bi_valid > 8) {
1172
        put_short(s, s->bi_buf);
1151
        put_short(s, s->bi_buf);
(-)a/uncompr.c (-10 / +4 lines)
Lines 24-34 Link Here
24
   Z_DATA_ERROR if the input data was corrupted, including if the input data is
24
   Z_DATA_ERROR if the input data was corrupted, including if the input data is
25
   an incomplete zlib stream.
25
   an incomplete zlib stream.
26
*/
26
*/
27
int ZEXPORT uncompress2(dest, destLen, source, sourceLen)
27
int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen, const Bytef *source,
28
    Bytef *dest;
28
                        uLongf *sourceLen)
29
    uLongf *destLen;
30
    const Bytef *source;
31
    uLong *sourceLen;
32
{
29
{
33
    z_stream stream;
30
    z_stream stream;
34
    int err;
31
    int err;
Lines 83-93 Link Here
83
           err;
80
           err;
84
}
81
}
85
82
86
int ZEXPORT uncompress(dest, destLen, source, sourceLen)
83
int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, const Bytef *source,
87
    Bytef *dest;
84
                       uLong sourceLen)
88
    uLongf *destLen;
89
    const Bytef *source;
90
    uLong sourceLen;
91
{
85
{
92
    return uncompress2(dest, destLen, source, &sourceLen);
86
    return uncompress2(dest, destLen, source, &sourceLen);
93
}
87
}
(-)a/zutil.c (-20 / +6 lines)
Lines 132-139 Link Here
132
/* exported to allow conversion of error code to string for compress() and
132
/* exported to allow conversion of error code to string for compress() and
133
 * uncompress()
133
 * uncompress()
134
 */
134
 */
135
const char * ZEXPORT zError(err)
135
const char * ZEXPORT zError(int err)
136
    int err;
137
{
136
{
138
    return ERR_MSG(err);
137
    return ERR_MSG(err);
139
}
138
}
Lines 148-157 Link Here
148
147
149
#ifndef HAVE_MEMCPY
148
#ifndef HAVE_MEMCPY
150
149
151
void ZLIB_INTERNAL zmemcpy(dest, source, len)
150
void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len)
152
    Bytef* dest;
153
    const Bytef* source;
154
    uInt  len;
155
{
151
{
156
    if (len == 0) return;
152
    if (len == 0) return;
157
    do {
153
    do {
Lines 159-168 Link Here
159
    } while (--len != 0);
155
    } while (--len != 0);
160
}
156
}
161
157
162
int ZLIB_INTERNAL zmemcmp(s1, s2, len)
158
int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len)
163
    const Bytef* s1;
164
    const Bytef* s2;
165
    uInt  len;
166
{
159
{
167
    uInt j;
160
    uInt j;
168
161
Lines 172-180 Link Here
172
    return 0;
165
    return 0;
173
}
166
}
174
167
175
void ZLIB_INTERNAL zmemzero(dest, len)
168
void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len)
176
    Bytef* dest;
177
    uInt  len;
178
{
169
{
179
    if (len == 0) return;
170
    if (len == 0) return;
180
    do {
171
    do {
Lines 304-322 Link Here
304
extern void   free   OF((voidpf ptr));
295
extern void   free   OF((voidpf ptr));
305
#endif
296
#endif
306
297
307
voidpf ZLIB_INTERNAL zcalloc(opaque, items, size)
298
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size)
308
    voidpf opaque;
309
    unsigned items;
310
    unsigned size;
311
{
299
{
312
    (void)opaque;
300
    (void)opaque;
313
    return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
301
    return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
314
                              (voidpf)calloc(items, size);
302
                              (voidpf)calloc(items, size);
315
}
303
}
316
304
317
void ZLIB_INTERNAL zcfree(opaque, ptr)
305
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr)
318
    voidpf opaque;
319
    voidpf ptr;
320
{
306
{
321
    (void)opaque;
307
    (void)opaque;
322
    free(ptr);
308
    free(ptr);

Return to bug 894598