memory, Z_BUF_ERROR if there was not enough room in the output buffer,
Z_STREAM_ERROR if the level parameter is invalid.
*/
-int ZEXPORT compress2(unsigned char *dest, unsigned long *destLen, const unsigned char *source,
- unsigned long sourceLen, int level) {
+int ZEXPORT compress2(unsigned char *dest, size_t *destLen, const unsigned char *source,
+ size_t sourceLen, int level) {
z_stream stream;
int err;
const unsigned int max = (unsigned int)0 - 1;
- unsigned long left;
+ size_t left;
left = *destLen;
*destLen = 0;
/* ===========================================================================
*/
-int ZEXPORT compress(unsigned char *dest, unsigned long *destLen, const unsigned char *source, unsigned long sourceLen) {
+int ZEXPORT compress(unsigned char *dest, size_t *destLen, const unsigned char *source, size_t sourceLen) {
return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
}
If the default memLevel or windowBits for deflateInit() is changed, then
this function needs to be updated.
*/
-unsigned long ZEXPORT compressBound(unsigned long sourceLen) {
+size_t ZEXPORT compressBound(size_t sourceLen) {
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + (sourceLen >> 25) + 13;
}
const char dictionary[] = "hello";
unsigned long dictId; /* Adler32 value of the dictionary */
-void test_deflate (unsigned char *compr, unsigned long comprLen);
-void test_inflate (unsigned char *compr, unsigned long comprLen, unsigned char *uncompr, unsigned long uncomprLen);
-void test_large_deflate (unsigned char *compr, unsigned long comprLen, unsigned char *uncompr, unsigned long uncomprLen);
-void test_large_inflate (unsigned char *compr, unsigned long comprLen, unsigned char *uncompr, unsigned long uncomprLen);
-void test_flush (unsigned char *compr, unsigned long *comprLen);
-void test_sync (unsigned char *compr, unsigned long comprLen, unsigned char *uncompr, unsigned long uncomprLen);
-void test_dict_deflate (unsigned char *compr, unsigned long comprLen);
-void test_dict_inflate (unsigned char *compr, unsigned long comprLen, unsigned char *uncompr, unsigned long uncomprLen);
+void test_deflate (unsigned char *compr, size_t comprLen);
+void test_inflate (unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen);
+void test_large_deflate (unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen);
+void test_large_inflate (unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen);
+void test_flush (unsigned char *compr, size_t *comprLen);
+void test_sync (unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen);
+void test_dict_deflate (unsigned char *compr, size_t comprLen);
+void test_dict_inflate (unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen);
int main (int argc, char *argv[]);
static alloc_func zalloc = (alloc_func)0;
static free_func zfree = (free_func)0;
-void test_compress (unsigned char *compr, unsigned long comprLen,
- unsigned char *uncompr, unsigned long uncomprLen);
+void test_compress (unsigned char *compr, size_t comprLen,
+ unsigned char *uncompr, size_t uncomprLen);
/* ===========================================================================
* Test compress() and uncompress()
*/
-void test_compress(unsigned char *compr, unsigned long comprLen, unsigned char *uncompr, unsigned long uncomprLen)
+void test_compress(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen)
{
int err;
- unsigned long len = (unsigned long)strlen(hello)+1;
+ size_t len = strlen(hello)+1;
err = compress(compr, &comprLen, (const unsigned char*)hello, len);
CHECK_ERR(err, "compress");
/* ===========================================================================
* Test deflate() with small buffers
*/
-void test_deflate(unsigned char *compr, unsigned long comprLen)
+void test_deflate(unsigned char *compr, size_t comprLen)
{
z_stream c_stream; /* compression stream */
int err;
/* ===========================================================================
* Test inflate() with small buffers
*/
-void test_inflate(unsigned char *compr, unsigned long comprLen, unsigned char *uncompr, unsigned long uncomprLen)
+void test_inflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen)
{
int err;
z_stream d_stream; /* decompression stream */
/* ===========================================================================
* Test deflate() with large buffers and dynamic change of compression level
*/
-void test_large_deflate(unsigned char *compr, unsigned long comprLen, unsigned char *uncompr, unsigned long uncomprLen)
+void test_large_deflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen)
{
z_stream c_stream; /* compression stream */
int err;
/* ===========================================================================
* Test inflate() with large buffers
*/
-void test_large_inflate(unsigned char *compr, unsigned long comprLen, unsigned char *uncompr, unsigned long uncomprLen)
+void test_large_inflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen)
{
int err;
z_stream d_stream; /* decompression stream */
CHECK_ERR(err, "inflateEnd");
if (d_stream.total_out != 2*uncomprLen + comprLen/2) {
- fprintf(stderr, "bad large inflate: %" PRId32 "\n", d_stream.total_out);
+ fprintf(stderr, "bad large inflate: %zu\n", d_stream.total_out);
exit(1);
} else {
printf("large_inflate(): OK\n");
/* ===========================================================================
* Test deflate() with full flush
*/
-void test_flush(unsigned char *compr, unsigned long *comprLen)
+void test_flush(unsigned char *compr, size_t *comprLen)
{
z_stream c_stream; /* compression stream */
int err;
/* ===========================================================================
* Test inflateSync()
*/
-void test_sync(unsigned char *compr, unsigned long comprLen, unsigned char *uncompr, unsigned long uncomprLen)
+void test_sync(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen)
{
int err;
z_stream d_stream; /* decompression stream */
/* ===========================================================================
* Test deflate() with preset dictionary
*/
-void test_dict_deflate(unsigned char *compr, unsigned long comprLen)
+void test_dict_deflate(unsigned char *compr, size_t comprLen)
{
z_stream c_stream; /* compression stream */
int err;
/* ===========================================================================
* Test inflate() with a preset dictionary
*/
-void test_dict_inflate(unsigned char *compr, unsigned long comprLen, unsigned char *uncompr, unsigned long uncomprLen)
+void test_dict_inflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen)
{
int err;
z_stream d_stream; /* decompression stream */
int main(int argc, char *argv[])
{
unsigned char *compr, *uncompr;
- unsigned long comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */
- unsigned long uncomprLen = comprLen;
+ size_t comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */
+ size_t uncomprLen = comprLen;
static const char* myVersion = ZLIB_VERSION;
if (zlibVersion()[0] != myVersion[0]) {
typedef struct z_stream_s {
const unsigned char *next_in; /* next input byte */
uint32_t avail_in; /* number of bytes available at next_in */
- uint32_t total_in; /* total number of input bytes read so far */
+ size_t total_in; /* total number of input bytes read so far */
unsigned char *next_out; /* next output byte should be put there */
uint32_t avail_out; /* remaining free space at next_out */
- uint32_t total_out; /* total number of bytes output so far */
+ size_t total_out; /* total number of bytes output so far */
const char *msg; /* last error message, NULL if no error */
struct internal_state *state; /* not visible by applications */
you need special options.
*/
-ZEXTERN int ZEXPORT compress(unsigned char *dest, unsigned long *destLen, const unsigned char *source, unsigned long sourceLen);
+ZEXTERN int ZEXPORT compress(unsigned char *dest, size_t *destLen, const unsigned char *source, size_t sourceLen);
/*
Compresses the source buffer into the destination buffer. sourceLen is
the byte length of the source buffer. Upon entry, destLen is the total size
buffer.
*/
-ZEXTERN int ZEXPORT compress2(unsigned char *dest, unsigned long *destLen, const unsigned char *source,
- unsigned long sourceLen, int level);
+ZEXTERN int ZEXPORT compress2(unsigned char *dest, size_t *destLen, const unsigned char *source,
+ size_t sourceLen, int level);
/*
Compresses the source buffer into the destination buffer. The level
parameter has the same meaning as in deflateInit. sourceLen is the byte
Z_STREAM_ERROR if the level parameter is invalid.
*/
-ZEXTERN unsigned long ZEXPORT compressBound(unsigned long sourceLen);
+ZEXTERN size_t ZEXPORT compressBound(size_t sourceLen);
/*
compressBound() returns an upper bound on the compressed size after
compress() or compress2() on sourceLen bytes. It would be used before a
compress() or compress2() call to allocate the destination buffer.
*/
-ZEXTERN int ZEXPORT uncompress(unsigned char *dest, unsigned long *destLen, const unsigned char *source, unsigned long sourceLen);
+ZEXTERN int ZEXPORT uncompress(unsigned char *dest, size_t *destLen, const unsigned char *source, size_t 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