Changeset e215a4e1 in rtems


Ignore:
Timestamp:
Mar 18, 2011, 10:11:28 AM (9 years ago)
Author:
Ralf Corsepius <ralf.corsepius@…>
Branches:
4.11, master
Children:
b40c451
Parents:
4b06f71a
Message:

Import from zlib-1.2.4

Location:
cpukit/zlib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/zlib/contrib/infback9/inftree9.c

    r4b06f71a re215a4e1  
    11/* inftree9.c -- generate Huffman trees for efficient decoding
    2  * Copyright (C) 1995-2005 Mark Adler
     2 * Copyright (C) 1995-2010 Mark Adler
    33 * For conditions of distribution and use, see copyright notice in zlib.h
    44 */
     
    1010
    1111const char inflate9_copyright[] =
    12    " inflate9 1.2.3 Copyright 1995-2005 Mark Adler ";
     12   " inflate9 1.2.4 Copyright 1995-2010 Mark Adler ";
    1313/*
    1414  If you use the zlib library in a product, an acknowledgment is welcome
     
    6565        128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129,
    6666        130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132,
    67         133, 133, 133, 133, 144, 201, 196};
     67        133, 133, 133, 133, 144, 64, 195};
    6868    static const unsigned short dbase[32] = { /* Distance codes 0..31 base */
    6969        1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49,
     
    161161
    162162       used keeps track of how many table entries have been allocated from the
    163        provided *table space.  It is checked when a LENS table is being made
    164        against the space in *table, ENOUGH, minus the maximum space needed by
    165        the worst case distance code, MAXD.  This should never happen, but the
    166        sufficiency of ENOUGH has not been proven exhaustively, hence the check.
    167        This assumes that when type == LENS, bits == 9.
     163       provided *table space.  It is checked for LENS and DIST tables against
     164       the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in
     165       the initial root table size constants.  See the comments in inftree9.h
     166       for more information.
    168167
    169168       sym increments through all symbols, and the loop terminates when
     
    204203
    205204    /* check available table space */
    206     if (type == LENS && used >= ENOUGH - MAXD)
     205    if ((type == LENS && used >= ENOUGH_LENS) ||
     206        (type == DISTS && used >= ENOUGH_DISTS))
    207207        return 1;
    208208
     
    271271            /* check for enough space */
    272272            used += 1U << curr;
    273             if (type == LENS && used >= ENOUGH - MAXD)
     273            if ((type == LENS && used >= ENOUGH_LENS) ||
     274                (type == DISTS && used >= ENOUGH_DISTS))
    274275                return 1;
    275276
  • cpukit/zlib/inftrees.c

    r4b06f71a re215a4e1  
    11/* inftrees.c -- generate Huffman trees for efficient decoding
    2  * Copyright (C) 1995-2005 Mark Adler
     2 * Copyright (C) 1995-2010 Mark Adler
    33 * For conditions of distribution and use, see copyright notice in zlib.h
    44 */
     
    1010
    1111const char inflate_copyright[] =
    12    " inflate 1.2.3 Copyright 1995-2005 Mark Adler ";
     12   " inflate 1.2.4 Copyright 1995-2010 Mark Adler ";
    1313/*
    1414  If you use the zlib library in a product, an acknowledgment is welcome
     
    5151    unsigned low;               /* low bits for current root entry */
    5252    unsigned mask;              /* mask for low root bits */
    53     code this;                  /* table entry for duplication */
     53    code here;                  /* table entry for duplication */
    5454    code FAR *next;             /* next available space in table */
    5555    const unsigned short FAR *base;     /* base value table to use */
     
    6363    static const unsigned short lext[31] = { /* Length codes 257..285 extra */
    6464        16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
    65         19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 201, 196};
     65        19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 64, 195};
    6666    static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
    6767        1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
     
    116116    if (root > max) root = max;
    117117    if (max == 0) {                     /* no symbols to code at all */
    118         this.op = (unsigned char)64;    /* invalid code marker */
    119         this.bits = (unsigned char)1;
    120         this.val = (unsigned short)0;
    121         *(*table)++ = this;             /* make a table to force an error */
    122         *(*table)++ = this;
     118        here.op = (unsigned char)64;    /* invalid code marker */
     119        here.bits = (unsigned char)1;
     120        here.val = (unsigned short)0;
     121        *(*table)++ = here;             /* make a table to force an error */
     122        *(*table)++ = here;
    123123        *bits = 1;
    124124        return 0;     /* no symbols, but wait for decoding to report error */
    125125    }
    126     for (min = 1; min <= MAXBITS; min++)
     126    for (min = 1; min < max; min++)
    127127        if (count[min] != 0) break;
    128128    if (root < min) root = min;
     
    167167
    168168       used keeps track of how many table entries have been allocated from the
    169        provided *table space.  It is checked when a LENS table is being made
    170        against the space in *table, ENOUGH, minus the maximum space needed by
    171        the worst case distance code, MAXD.  This should never happen, but the
    172        sufficiency of ENOUGH has not been proven exhaustively, hence the check.
    173        This assumes that when type == LENS, bits == 9.
     169       provided *table space.  It is checked for LENS and DIST tables against
     170       the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in
     171       the initial root table size constants.  See the comments in inftrees.h
     172       for more information.
    174173
    175174       sym increments through all symbols, and the loop terminates when
     
    210209
    211210    /* check available table space */
    212     if (type == LENS && used >= ENOUGH - MAXD)
     211    if ((type == LENS && used >= ENOUGH_LENS) ||
     212        (type == DISTS && used >= ENOUGH_DISTS))
    213213        return 1;
    214214
     
    216216    for (;;) {
    217217        /* create table entry */
    218         this.bits = (unsigned char)(len - drop);
     218        here.bits = (unsigned char)(len - drop);
    219219        if ((int)(work[sym]) < end) {
    220             this.op = (unsigned char)0;
    221             this.val = work[sym];
     220            here.op = (unsigned char)0;
     221            here.val = work[sym];
    222222        }
    223223        else if ((int)(work[sym]) > end) {
    224             this.op = (unsigned char)(extra[work[sym]]);
    225             this.val = base[work[sym]];
     224            here.op = (unsigned char)(extra[work[sym]]);
     225            here.val = base[work[sym]];
    226226        }
    227227        else {
    228             this.op = (unsigned char)(32 + 64);         /* end of block */
    229             this.val = 0;
     228            here.op = (unsigned char)(32 + 64);         /* end of block */
     229            here.val = 0;
    230230        }
    231231
     
    236236        do {
    237237            fill -= incr;
    238             next[(huff >> drop) + fill] = this;
     238            next[(huff >> drop) + fill] = here;
    239239        } while (fill != 0);
    240240
     
    278278            /* check for enough space */
    279279            used += 1U << curr;
    280             if (type == LENS && used >= ENOUGH - MAXD)
     280            if ((type == LENS && used >= ENOUGH_LENS) ||
     281                (type == DISTS && used >= ENOUGH_DISTS))
    281282                return 1;
    282283
     
    296297       drops back to the root table to fill in any remaining entries there.
    297298     */
    298     this.op = (unsigned char)64;                /* invalid code marker */
    299     this.bits = (unsigned char)(len - drop);
    300     this.val = (unsigned short)0;
     299    here.op = (unsigned char)64;                /* invalid code marker */
     300    here.bits = (unsigned char)(len - drop);
     301    here.val = (unsigned short)0;
    301302    while (huff != 0) {
    302303        /* when done with sub-table, drop back to root table */
     
    305306            len = root;
    306307            next = *table;
    307             this.bits = (unsigned char)len;
     308            here.bits = (unsigned char)len;
    308309        }
    309310
    310311        /* put invalid code marker in table */
    311         next[huff >> drop] = this;
     312        next[huff >> drop] = here;
    312313
    313314        /* backwards increment the len-bit code huff */
Note: See TracChangeset for help on using the changeset viewer.