The R Project SVN R

Rev

Rev 17798 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 17798 Rev 18679
Line 1... Line 1...
1
/* inftrees.c -- generate Huffman trees for efficient decoding
1
/* inftrees.c -- generate Huffman trees for efficient decoding
2
 * Copyright (C) 1995-1998 Mark Adler
2
 * Copyright (C) 1995-2002 Mark Adler
3
 * For conditions of distribution and use, see copyright notice in zlib.h 
3
 * For conditions of distribution and use, see copyright notice in zlib.h 
4
 */
4
 */
5
 
5
 
6
#include "zutil.h"
6
#include "zutil.h"
7
#include "inftrees.h"
7
#include "inftrees.h"
Line 9... Line 9...
9
#if !defined(BUILDFIXED) && !defined(STDC)
9
#if !defined(BUILDFIXED) && !defined(STDC)
10
#  define BUILDFIXED   /* non ANSI compilers may not accept inffixed.h */
10
#  define BUILDFIXED   /* non ANSI compilers may not accept inffixed.h */
11
#endif
11
#endif
12
 
12
 
13
const char inflate_copyright[] =
13
const char inflate_copyright[] =
14
   " inflate 1.1.3 Copyright 1995-1998 Mark Adler ";
14
   " inflate 1.1.4 Copyright 1995-2002 Mark Adler ";
15
/*
15
/*
16
  If you use the zlib library in a product, an acknowledgment is welcome
16
  If you use the zlib library in a product, an acknowledgment is welcome
17
  in the documentation of your product. If for some reason you cannot
17
  in the documentation of your product. If for some reason you cannot
18
  include such an acknowledgment, I would appreciate that you keep this
18
  include such an acknowledgment, I would appreciate that you keep this
19
  copyright string in the executable of your product.
19
  copyright string in the executable of your product.
Line 102... Line 102...
102
uInt *hn;               /* hufts used in space */
102
uInt *hn;               /* hufts used in space */
103
uIntf *v;               /* working area: values in order of bit length */
103
uIntf *v;               /* working area: values in order of bit length */
104
/* Given a list of code lengths and a maximum table size, make a set of
104
/* Given a list of code lengths and a maximum table size, make a set of
105
   tables to decode that set of codes.  Return Z_OK on success, Z_BUF_ERROR
105
   tables to decode that set of codes.  Return Z_OK on success, Z_BUF_ERROR
106
   if the given code set is incomplete (the tables are still built in this
106
   if the given code set is incomplete (the tables are still built in this
107
   case), Z_DATA_ERROR if the input is invalid (an over-subscribed set of
107
   case), or Z_DATA_ERROR if the input is invalid. */
108
   lengths), or Z_MEM_ERROR if not enough memory. */
-
 
109
{
108
{
110
 
109
 
111
  uInt a;                       /* counter for codes of length k */
110
  uInt a;                       /* counter for codes of length k */
112
  uInt c[BMAX+1];               /* bit length count table */
111
  uInt c[BMAX+1];               /* bit length count table */
113
  uInt f;                       /* i repeats in table every f entries */
112
  uInt f;                       /* i repeats in table every f entries */
Line 229... Line 228...
229
        }
228
        }
230
        z = 1 << j;             /* table entries for j-bit table */
229
        z = 1 << j;             /* table entries for j-bit table */
231
 
230
 
232
        /* allocate new table */
231
        /* allocate new table */
233
        if (*hn + z > MANY)     /* (note: doesn't matter for fixed) */
232
        if (*hn + z > MANY)     /* (note: doesn't matter for fixed) */
234
          return Z_MEM_ERROR;   /* not enough memory */
233
          return Z_DATA_ERROR;  /* overflow of MANY */
235
        u[h] = q = hp + *hn;
234
        u[h] = q = hp + *hn;
236
        *hn += z;
235
        *hn += z;
237
 
236
 
238
        /* connect to last table, if there is one */
237
        /* connect to last table, if there is one */
239
        if (h)
238
        if (h)