diff options
Diffstat (limited to 'zlib/uncompr.c')
-rw-r--r-- | zlib/uncompr.c | 52 |
1 files changed, 22 insertions, 30 deletions
diff --git a/zlib/uncompr.c b/zlib/uncompr.c index d7eaf2e4c..54e3a63b7 100644 --- a/zlib/uncompr.c +++ b/zlib/uncompr.c @@ -1,41 +1,33 @@ -/* @(#) $Id: uncompr.c,v 1.4 2002/02/10 16:50:06 jbj Exp $ */ -/* +/* uncompr.c -- decompress a memory buffer * Copyright (C) 1995-2002 Jean-loup Gailly. * For conditions of distribution and use, see copyright notice in zlib.h */ -/** - * \file uncompr.c - * Decompress a memory buffer. - */ +/* @(#) $Id$ */ #include "zlib.h" -#include "zutil.h" /* XXX for zmemzero() */ - -/*@access z_streamp@*/ - -/* ========================================================================= */ -/** - * Decompresses the source buffer into the destination buffer. sourceLen is - * the byte length of the source buffer. Upon entry, destLen is the total - * size of the destination buffer, which must be large enough to hold the - * entire uncompressed data. (The size of the uncompressed data must have - * been saved previously by the compressor and transmitted to the decompressor - * by some mechanism outside the scope of this compression library.) - * Upon exit, destLen is the actual size of the compressed buffer. - * This function can be used to decompress a whole file at once if the - * input file is mmap'ed. - * - * uncompress returns Z_OK if success, Z_MEM_ERROR if there was not - * enough memory, Z_BUF_ERROR if there was not enough room in the output - * buffer, or Z_DATA_ERROR if the input data was corrupted. - */ -int ZEXPORT uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen) + +/* =========================================================================== + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be large enough to hold the + entire uncompressed data. (The size of the uncompressed data must have + been saved previously by the compressor and transmitted to the decompressor + by some mechanism outside the scope of this compression library.) + Upon exit, destLen is the actual size of the compressed buffer. + This function can be used to decompress a whole file at once if the + input file is mmap'ed. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted. +*/ +int ZEXPORT uncompress (Bytef * dest, uLongf * destLen, const Bytef * source, + uLong sourceLen) { z_stream stream; int err; - zmemzero(&stream, sizeof(stream)); stream.next_in = (Bytef*)source; stream.avail_in = (uInt)sourceLen; /* Check for source > 64K on 16-bit machine: */ @@ -45,8 +37,8 @@ int ZEXPORT uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong stream.avail_out = (uInt)*destLen; if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; - stream.zalloc = (alloc_func)NULL; - stream.zfree = (free_func)NULL; + stream.zalloc = (alloc_func)0; + stream.zfree = (free_func)0; err = inflateInit(&stream); if (err != Z_OK) return err; |