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
6 /* @(#) $Id: uncompr.c,v 1.1.1.2 2002/03/11 21:53:27 tromey Exp $ */
11 /* ===========================================================================
12 Decompresses the source buffer into the destination buffer. sourceLen is
13 the byte length of the source buffer. Upon entry, destLen is the total
14 size of the destination buffer, which must be large enough to hold the
15 entire uncompressed data. (The size of the uncompressed data must have
16 been saved previously by the compressor and transmitted to the decompressor
17 by some mechanism outside the scope of this compression library.)
18 Upon exit, destLen is the actual size of the compressed buffer.
20 uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
21 enough memory, Z_BUF_ERROR if there was not enough room in the output
22 buffer, or Z_DATA_ERROR if the input data was corrupted.
24 int ZEXPORT
uncompress (dest
, destLen
, source
, sourceLen
)
33 stream
.next_in
= (Bytef
*)source
;
34 stream
.avail_in
= (uInt
)sourceLen
;
35 /* Check for source > 64K on 16-bit machine: */
36 if ((uLong
)stream
.avail_in
!= sourceLen
) return Z_BUF_ERROR
;
38 stream
.next_out
= dest
;
39 stream
.avail_out
= (uInt
)*destLen
;
40 if ((uLong
)stream
.avail_out
!= *destLen
) return Z_BUF_ERROR
;
42 stream
.zalloc
= (alloc_func
)0;
43 stream
.zfree
= (free_func
)0;
45 err
= inflateInit(&stream
);
46 if (err
!= Z_OK
) return err
;
48 err
= inflate(&stream
, Z_FINISH
);
49 if (err
!= Z_STREAM_END
) {
51 if (err
== Z_NEED_DICT
|| (err
== Z_BUF_ERROR
&& stream
.avail_in
== 0))
55 *destLen
= stream
.total_out
;
57 err
= inflateEnd(&stream
);
This page took 0.030132 seconds and 4 git commands to generate.