source: rtems/cpukit/zlib/uncompr.c @ bdd4eb87

5
Last change on this file since bdd4eb87 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 1.9 KB
Line 
1/* uncompr.c -- decompress a memory buffer
2 * Copyright (C) 1995-2003, 2010 Jean-loup Gailly.
3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */
5
6#define ZLIB_INTERNAL
7#include "zlib.h"
8
9/* ===========================================================================
10     Decompresses the source buffer into the destination buffer.  sourceLen is
11   the byte length of the source buffer. Upon entry, destLen is the total
12   size of the destination buffer, which must be large enough to hold the
13   entire uncompressed data. (The size of the uncompressed data must have
14   been saved previously by the compressor and transmitted to the decompressor
15   by some mechanism outside the scope of this compression library.)
16   Upon exit, destLen is the actual size of the compressed buffer.
17
18     uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
19   enough memory, Z_BUF_ERROR if there was not enough room in the output
20   buffer, or Z_DATA_ERROR if the input data was corrupted.
21*/
22int ZEXPORT uncompress (dest, destLen, source, sourceLen)
23    Bytef *dest;
24    uLongf *destLen;
25    const Bytef *source;
26    uLong sourceLen;
27{
28    z_stream stream;
29    int err;
30
31    stream.next_in = (Bytef*)source;
32    stream.avail_in = (uInt)sourceLen;
33    /* Check for source > 64K on 16-bit machine: */
34    if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
35
36    stream.next_out = dest;
37    stream.avail_out = (uInt)*destLen;
38    if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
39
40    stream.zalloc = (alloc_func)0;
41    stream.zfree = (free_func)0;
42
43    err = inflateInit(&stream);
44    if (err != Z_OK) return err;
45
46    err = inflate(&stream, Z_FINISH);
47    if (err != Z_STREAM_END) {
48        inflateEnd(&stream);
49        if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0))
50            return Z_DATA_ERROR;
51        return err;
52    }
53    *destLen = stream.total_out;
54
55    err = inflateEnd(&stream);
56    return err;
57}
Note: See TracBrowser for help on using the repository browser.