Changeset 8198f69 in rtems for cpukit/zlib/inflate.c


Ignore:
Timestamp:
Mar 18, 2011, 10:10:55 AM (9 years ago)
Author:
Ralf Corsepius <ralf.corsepius@…>
Branches:
4.11, master
Children:
a7aa735
Parents:
e7fc2fd
Message:

Import zlib-1.2.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/zlib/inflate.c

    re7fc2fd r8198f69  
    11/* inflate.c -- zlib decompression
    2  * Copyright (C) 1995-2004 Mark Adler
     2 * Copyright (C) 1995-2005 Mark Adler
    33 * For conditions of distribution and use, see copyright notice in zlib.h
    44 */
     
    118118    state->wsize = 0;
    119119    state->whave = 0;
     120    state->write = 0;
    120121    state->hold = 0;
    121122    state->bits = 0;
    122123    state->lencode = state->distcode = state->next = state->codes;
    123124    Tracev((stderr, "inflate: reset\n"));
     125    return Z_OK;
     126}
     127
     128int ZEXPORT inflatePrime(strm, bits, value)
     129z_streamp strm;
     130int bits;
     131int value;
     132{
     133    struct inflate_state FAR *state;
     134
     135    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
     136    state = (struct inflate_state FAR *)strm->state;
     137    if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR;
     138    value &= (1L << bits) - 1;
     139    state->hold += value << state->bits;
     140    state->bits += bits;
    124141    return Z_OK;
    125142}
     
    147164    if (state == Z_NULL) return Z_MEM_ERROR;
    148165    Tracev((stderr, "inflate: allocated\n"));
    149     strm->state = (voidpf)state;
     166    strm->state = (struct internal_state FAR *)state;
    150167    if (windowBits < 0) {
    151168        state->wrap = 0;
     
    13111328    struct inflate_state FAR *copy;
    13121329    unsigned char FAR *window;
     1330    unsigned wsize;
    13131331
    13141332    /* check input */
     
    13351353    zmemcpy(dest, source, sizeof(z_stream));
    13361354    zmemcpy(copy, state, sizeof(struct inflate_state));
    1337     copy->lencode = copy->codes + (state->lencode - state->codes);
    1338     copy->distcode = copy->codes + (state->distcode - state->codes);
     1355    if (state->lencode >= state->codes &&
     1356        state->lencode <= state->codes + ENOUGH - 1) {
     1357        copy->lencode = copy->codes + (state->lencode - state->codes);
     1358        copy->distcode = copy->codes + (state->distcode - state->codes);
     1359    }
    13391360    copy->next = copy->codes + (state->next - state->codes);
    1340     if (window != Z_NULL)
    1341         zmemcpy(window, state->window, 1U << state->wbits);
     1361    if (window != Z_NULL) {
     1362        wsize = 1U << state->wbits;
     1363        zmemcpy(window, state->window, wsize);
     1364    }
    13421365    copy->window = window;
    1343     dest->state = (voidpf)copy;
     1366    dest->state = (struct internal_state FAR *)copy;
    13441367    return Z_OK;
    13451368}
Note: See TracChangeset for help on using the changeset viewer.