misc/libfreetype/src/gzip/infblock.c
author Xeli
Sat, 12 Nov 2011 14:50:35 +0100
branchhedgeroid
changeset 6232 cf4b0f43d64d
parent 5172 88f2e05288ba
permissions -rw-r--r--
removed sdl_net which was 'borrowed' (?:P) from peyla's port we'll now be using the official port
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5172
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     1
/* infblock.c -- interpret and process block types to last block
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     2
 * Copyright (C) 1995-2002 Mark Adler
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     3
 * For conditions of distribution and use, see copyright notice in zlib.h
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     4
 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     5
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     6
#include "zutil.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     7
#include "infblock.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     8
#include "inftrees.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     9
#include "infcodes.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    10
#include "infutil.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    11
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    12
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    13
/* simplify the use of the inflate_huft type with some defines */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    14
#define exop word.what.Exop
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    15
#define bits word.what.Bits
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    16
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    17
/* Table for deflate from PKZIP's appnote.txt. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    18
local const uInt border[] = { /* Order of the bit length code lengths */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    19
        16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    20
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
/*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    22
   Notes beyond the 1.93a appnote.txt:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    24
   1. Distance pointers never point before the beginning of the output
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    25
      stream.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    26
   2. Distance pointers can point back across blocks, up to 32k away.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    27
   3. There is an implied maximum of 7 bits for the bit length table and
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
      15 bits for the actual data.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    29
   4. If only one code exists, then it is encoded using one bit.  (Zero
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    30
      would be more efficient, but perhaps a little confusing.)  If two
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    31
      codes exist, they are coded using one bit each (0 and 1).
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    32
   5. There is no way of sending zero distance codes--a dummy must be
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    33
      sent if there are none.  (History: a pre 2.0 version of PKZIP would
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    34
      store blocks with no distance codes, but this was discovered to be
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    35
      too harsh a criterion.)  Valid only for 1.93a.  2.04c does allow
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    36
      zero distance codes, which is sent as one code of zero bits in
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    37
      length.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    38
   6. There are up to 286 literal/length codes.  Code 256 represents the
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    39
      end-of-block.  Note however that the static length tree defines
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    40
      288 codes just to fill out the Huffman codes.  Codes 286 and 287
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    41
      cannot be used though, since there is no length base or extra bits
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    42
      defined for them.  Similarily, there are up to 30 distance codes.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    43
      However, static trees define 32 codes (all 5 bits) to fill out the
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    44
      Huffman codes, but the last two had better not show up in the data.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
   7. Unzip can check dynamic Huffman blocks for complete code sets.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
      The exception is that a single code would not be complete (see #4).
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
   8. The five bits following the block type is really the number of
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
      literal codes sent minus 257.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
   9. Length codes 8,16,16 are interpreted as 13 length codes of 8 bits
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
      (1+6+6).  Therefore, to output three times the length, you output
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
      three codes (1+1+1), whereas to output four times the same length,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
      you only need two codes (1+3).  Hmm.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
  10. In the tree reconstruction algorithm, Code = Code + Increment
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
      only if BitLength(i) is not zero.  (Pretty obvious.)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
  11. Correction: 4 Bits: # of Bit Length codes - 4     (4 - 19)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
  12. Note: length code 284 can represent 227-258, but length code 285
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
      really is 258.  The last length deserves its own, short code
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
      since it gets used a lot in very redundant files.  The length
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
      258 is special since 258 - 3 (the min match length) is 255.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
  13. The literal/length and distance code bit lengths are read as a
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
      single stream of lengths.  It is possible (and advantageous) for
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
      a repeat code (16, 17, or 18) to go across the boundary between
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
      the two sets of lengths.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
local void inflate_blocks_reset( /* s, z, c) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
inflate_blocks_statef *s,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
z_streamp z,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
uLongf *c )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
{
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
  if (c != Z_NULL)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
    *c = s->check;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
  if (s->mode == BTREE || s->mode == DTREE)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
    ZFREE(z, s->sub.trees.blens);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
  if (s->mode == CODES)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    77
    inflate_codes_free(s->sub.decode.codes, z);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
  s->mode = TYPE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
  s->bitk = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    80
  s->bitb = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    81
  s->read = s->write = s->window;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
  if (s->checkfn != Z_NULL)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
    z->adler = s->check = (*s->checkfn)(0L, (const Bytef *)Z_NULL, 0);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
  Tracev((stderr, "inflate:   blocks reset\n"));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
local inflate_blocks_statef *inflate_blocks_new( /* z, c, w) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
z_streamp z,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
check_func c,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
uInt w )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
{
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
  inflate_blocks_statef *s;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
  if ((s = (inflate_blocks_statef *)ZALLOC
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
       (z,1,sizeof(struct inflate_blocks_state))) == Z_NULL)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    97
    return s;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
  if ((s->hufts =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    99
       (inflate_huft *)ZALLOC(z, sizeof(inflate_huft), MANY)) == Z_NULL)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   100
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
    ZFREE(z, s);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   102
    return Z_NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   103
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
  if ((s->window = (Bytef *)ZALLOC(z, 1, w)) == Z_NULL)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   105
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   106
    ZFREE(z, s->hufts);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
    ZFREE(z, s);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
    return Z_NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   110
  s->end = s->window + w;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
  s->checkfn = c;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
  s->mode = TYPE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
  Tracev((stderr, "inflate:   blocks allocated\n"));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
  inflate_blocks_reset(s, z, Z_NULL);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   115
  return s;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   116
}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   117
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   118
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   119
local int inflate_blocks( /* s, z, r) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
inflate_blocks_statef *s,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   121
z_streamp z,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   122
int r )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   123
{
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
  uInt t;               /* temporary storage */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
  uLong b;              /* bit buffer */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
  uInt k;               /* bits in bit buffer */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   127
  Bytef *p;             /* input data pointer */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   128
  uInt n;               /* bytes available there */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
  Bytef *q;             /* output window write pointer */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
  uInt m;               /* bytes to end of window or read pointer */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
  /* copy input/output information to locals (UPDATE macro restores) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   133
  LOAD
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   134
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
  /* process input based on current state */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
  while (1) switch (s->mode)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
    case TYPE:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
      NEEDBITS(3)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
      t = (uInt)b & 7;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
      s->last = t & 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   142
      switch (t >> 1)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   143
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   144
        case 0:                         /* stored */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
          Tracev((stderr, "inflate:     stored block%s\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
                 s->last ? " (last)" : ""));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
          DUMPBITS(3)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
          t = k & 7;                    /* go to byte boundary */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   149
          DUMPBITS(t)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   150
          s->mode = LENS;               /* get length of stored block */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   152
        case 1:                         /* fixed */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
          Tracev((stderr, "inflate:     fixed codes block%s\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   154
                 s->last ? " (last)" : ""));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   155
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
            uInt bl, bd;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
            inflate_huft *tl, *td;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   159
            inflate_trees_fixed(&bl, &bd, (const inflate_huft**)&tl,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   160
                                          (const inflate_huft**)&td, z);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
            s->sub.decode.codes = inflate_codes_new(bl, bd, tl, td, z);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
            if (s->sub.decode.codes == Z_NULL)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   164
              r = Z_MEM_ERROR;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
              LEAVE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   167
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
          DUMPBITS(3)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
          s->mode = CODES;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   171
        case 2:                         /* dynamic */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   172
          Tracev((stderr, "inflate:     dynamic codes block%s\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   173
                 s->last ? " (last)" : ""));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   174
          DUMPBITS(3)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
          s->mode = TABLE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
        case 3:                         /* illegal */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
          DUMPBITS(3)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
          s->mode = BAD;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
          z->msg = (char*)"invalid block type";
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
          r = Z_DATA_ERROR;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   182
          LEAVE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   185
    case LENS:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   186
      NEEDBITS(32)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   187
      if ((((~b) >> 16) & 0xffff) != (b & 0xffff))
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   188
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   189
        s->mode = BAD;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
        z->msg = (char*)"invalid stored block lengths";
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   191
        r = Z_DATA_ERROR;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   192
        LEAVE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   193
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   194
      s->sub.left = (uInt)b & 0xffff;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   195
      b = k = 0;                      /* dump bits */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
      Tracev((stderr, "inflate:       stored length %u\n", s->sub.left));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
      s->mode = s->sub.left ? STORED : (s->last ? DRY : TYPE);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   198
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   199
    case STORED:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
      if (n == 0)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   201
        LEAVE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   202
      NEEDOUT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   203
      t = s->sub.left;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
      if (t > n) t = n;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
      if (t > m) t = m;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
      zmemcpy(q, p, t);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   207
      p += t;  n -= t;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   208
      q += t;  m -= t;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   209
      if ((s->sub.left -= t) != 0)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   210
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   211
      Tracev((stderr, "inflate:       stored end, %lu total out\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   212
              z->total_out + (q >= s->read ? q - s->read :
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   213
              (s->end - s->read) + (q - s->window))));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
      s->mode = s->last ? DRY : TYPE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   215
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   216
    case TABLE:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   217
      NEEDBITS(14)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
      s->sub.trees.table = t = (uInt)b & 0x3fff;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   219
#ifndef PKZIP_BUG_WORKAROUND
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   220
      if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   222
        s->mode = BAD;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   223
        z->msg = (char*)"too many length or distance symbols";
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   224
        r = Z_DATA_ERROR;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
        LEAVE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   227
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   228
      t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   229
      if ((s->sub.trees.blens = (uIntf*)ZALLOC(z, t, sizeof(uInt))) == Z_NULL)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   230
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   231
        r = Z_MEM_ERROR;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   232
        LEAVE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   234
      DUMPBITS(14)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   235
      s->sub.trees.index = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   236
      Tracev((stderr, "inflate:       table sizes ok\n"));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   237
      s->mode = BTREE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
    case BTREE:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   239
      while (s->sub.trees.index < 4 + (s->sub.trees.table >> 10))
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   240
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   241
        NEEDBITS(3)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   242
        s->sub.trees.blens[border[s->sub.trees.index++]] = (uInt)b & 7;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   243
        DUMPBITS(3)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   244
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   245
      while (s->sub.trees.index < 19)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   246
        s->sub.trees.blens[border[s->sub.trees.index++]] = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   247
      s->sub.trees.bb = 7;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   248
      t = inflate_trees_bits(s->sub.trees.blens, &s->sub.trees.bb,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   249
                             &s->sub.trees.tb, s->hufts, z);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   250
      if (t != Z_OK)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   251
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   252
        r = t;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   253
        if (r == Z_DATA_ERROR)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   254
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   255
          ZFREE(z, s->sub.trees.blens);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
          s->mode = BAD;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   258
        LEAVE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   259
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   260
      s->sub.trees.index = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   261
      Tracev((stderr, "inflate:       bits tree ok\n"));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   262
      s->mode = DTREE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   263
    case DTREE:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   264
      while (t = s->sub.trees.table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   265
             s->sub.trees.index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f))
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
        inflate_huft *h;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   268
        uInt i, j, c;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   269
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   270
        t = s->sub.trees.bb;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
        NEEDBITS(t)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   272
        h = s->sub.trees.tb + ((uInt)b & inflate_mask[t]);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   273
        t = h->bits;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   274
        c = h->base;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   275
        if (c < 16)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   276
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   277
          DUMPBITS(t)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   278
          s->sub.trees.blens[s->sub.trees.index++] = c;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
        else /* c == 16..18 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   281
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   282
          i = c == 18 ? 7 : c - 14;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   283
          j = c == 18 ? 11 : 3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   284
          NEEDBITS(t + i)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   285
          DUMPBITS(t)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   286
          j += (uInt)b & inflate_mask[i];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   287
          DUMPBITS(i)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   288
          i = s->sub.trees.index;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   289
          t = s->sub.trees.table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   290
          if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   291
              (c == 16 && i < 1))
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   292
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   293
            ZFREE(z, s->sub.trees.blens);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   294
            s->mode = BAD;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   295
            z->msg = (char*)"invalid bit length repeat";
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   296
            r = Z_DATA_ERROR;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   297
            LEAVE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   298
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   299
          c = c == 16 ? s->sub.trees.blens[i - 1] : 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   300
          do {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   301
            s->sub.trees.blens[i++] = c;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   302
          } while (--j);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   303
          s->sub.trees.index = i;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   304
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   305
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   306
      s->sub.trees.tb = Z_NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   307
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   308
        uInt bl, bd;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   309
        inflate_huft *tl, *td;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   310
        inflate_codes_statef *c;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   311
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   312
        bl = 9;         /* must be <= 9 for lookahead assumptions */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   313
        bd = 6;         /* must be <= 9 for lookahead assumptions */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   314
        t = s->sub.trees.table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   315
        t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   316
                                  s->sub.trees.blens, &bl, &bd, &tl, &td,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   317
                                  s->hufts, z);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   318
        if (t != Z_OK)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   319
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   320
          if (t == (uInt)Z_DATA_ERROR)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   321
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   322
            ZFREE(z, s->sub.trees.blens);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   323
            s->mode = BAD;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   324
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   325
          r = t;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   326
          LEAVE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   327
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   328
        Tracev((stderr, "inflate:       trees ok\n"));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   329
        if ((c = inflate_codes_new(bl, bd, tl, td, z)) == Z_NULL)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   330
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   331
          r = Z_MEM_ERROR;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   332
          LEAVE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   333
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   334
        s->sub.decode.codes = c;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   335
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   336
      ZFREE(z, s->sub.trees.blens);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   337
      s->mode = CODES;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   338
    case CODES:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   339
      UPDATE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   340
      if ((r = inflate_codes(s, z, r)) != Z_STREAM_END)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   341
        return inflate_flush(s, z, r);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   342
      r = Z_OK;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   343
      inflate_codes_free(s->sub.decode.codes, z);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   344
      LOAD
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   345
      Tracev((stderr, "inflate:       codes end, %lu total out\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   346
              z->total_out + (q >= s->read ? q - s->read :
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   347
              (s->end - s->read) + (q - s->window))));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   348
      if (!s->last)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   349
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   350
        s->mode = TYPE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   351
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   352
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   353
      s->mode = DRY;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   354
    case DRY:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   355
      FLUSH
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   356
      if (s->read != s->write)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   357
        LEAVE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   358
      s->mode = DONE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   359
    case DONE:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   360
      r = Z_STREAM_END;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   361
      LEAVE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   362
    case BAD:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   363
      r = Z_DATA_ERROR;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   364
      LEAVE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   365
    default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   366
      r = Z_STREAM_ERROR;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   367
      LEAVE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   368
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   369
#ifdef NEED_DUMMY_RETURN
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   370
  return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   371
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   372
}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   373
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   374
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   375
local int inflate_blocks_free( /* s, z) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   376
inflate_blocks_statef *s,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   377
z_streamp z )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   378
{
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   379
  inflate_blocks_reset(s, z, Z_NULL);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   380
  ZFREE(z, s->window);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   381
  ZFREE(z, s->hufts);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   382
  ZFREE(z, s);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   383
  Tracev((stderr, "inflate:   blocks freed\n"));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   384
  return Z_OK;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   385
}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   386
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   387