added uncompress2
This commit is contained in:
parent
e48d8bab88
commit
ccff20b76d
13
miniz.c
13
miniz.c
@ -552,19 +552,18 @@ int mz_inflateEnd(mz_streamp pStream)
|
|||||||
}
|
}
|
||||||
return MZ_OK;
|
return MZ_OK;
|
||||||
}
|
}
|
||||||
|
int mz_uncompress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong *pSource_len)
|
||||||
int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len)
|
|
||||||
{
|
{
|
||||||
mz_stream stream;
|
mz_stream stream;
|
||||||
int status;
|
int status;
|
||||||
memset(&stream, 0, sizeof(stream));
|
memset(&stream, 0, sizeof(stream));
|
||||||
|
|
||||||
/* In case mz_ulong is 64-bits (argh I hate longs). */
|
/* In case mz_ulong is 64-bits (argh I hate longs). */
|
||||||
if ((source_len | *pDest_len) > 0xFFFFFFFFU)
|
if ((*pSource_len | *pDest_len) > 0xFFFFFFFFU)
|
||||||
return MZ_PARAM_ERROR;
|
return MZ_PARAM_ERROR;
|
||||||
|
|
||||||
stream.next_in = pSource;
|
stream.next_in = pSource;
|
||||||
stream.avail_in = (mz_uint32)source_len;
|
stream.avail_in = (mz_uint32)*pSource_len;
|
||||||
stream.next_out = pDest;
|
stream.next_out = pDest;
|
||||||
stream.avail_out = (mz_uint32)*pDest_len;
|
stream.avail_out = (mz_uint32)*pDest_len;
|
||||||
|
|
||||||
@ -573,6 +572,7 @@ int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char
|
|||||||
return status;
|
return status;
|
||||||
|
|
||||||
status = mz_inflate(&stream, MZ_FINISH);
|
status = mz_inflate(&stream, MZ_FINISH);
|
||||||
|
*pSource_len = *pSource_len - stream.avail_in;
|
||||||
if (status != MZ_STREAM_END)
|
if (status != MZ_STREAM_END)
|
||||||
{
|
{
|
||||||
mz_inflateEnd(&stream);
|
mz_inflateEnd(&stream);
|
||||||
@ -583,6 +583,11 @@ int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char
|
|||||||
return mz_inflateEnd(&stream);
|
return mz_inflateEnd(&stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len)
|
||||||
|
{
|
||||||
|
return mz_uncompress2(pDest, pDest_len, pSource, &source_len);
|
||||||
|
}
|
||||||
|
|
||||||
const char *mz_error(int err)
|
const char *mz_error(int err)
|
||||||
{
|
{
|
||||||
static struct
|
static struct
|
||||||
|
|||||||
2
miniz.h
2
miniz.h
@ -388,6 +388,7 @@ MINIZ_EXPORT int mz_inflateEnd(mz_streamp pStream);
|
|||||||
/* Single-call decompression. */
|
/* Single-call decompression. */
|
||||||
/* Returns MZ_OK on success, or one of the error codes from mz_inflate() on failure. */
|
/* Returns MZ_OK on success, or one of the error codes from mz_inflate() on failure. */
|
||||||
MINIZ_EXPORT int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len);
|
MINIZ_EXPORT int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len);
|
||||||
|
MINIZ_EXPORT int mz_uncompress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong *pSource_len);
|
||||||
|
|
||||||
/* Returns a string description of the specified error code, or NULL if the error code is invalid. */
|
/* Returns a string description of the specified error code, or NULL if the error code is invalid. */
|
||||||
MINIZ_EXPORT const char *mz_error(int err);
|
MINIZ_EXPORT const char *mz_error(int err);
|
||||||
@ -453,6 +454,7 @@ typedef void *const voidpc;
|
|||||||
#define inflate mz_inflate
|
#define inflate mz_inflate
|
||||||
#define inflateEnd mz_inflateEnd
|
#define inflateEnd mz_inflateEnd
|
||||||
#define uncompress mz_uncompress
|
#define uncompress mz_uncompress
|
||||||
|
#define uncompress2 mz_uncompress2
|
||||||
#define crc32 mz_crc32
|
#define crc32 mz_crc32
|
||||||
#define adler32 mz_adler32
|
#define adler32 mz_adler32
|
||||||
#define MAX_WBITS 15
|
#define MAX_WBITS 15
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user