]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Replace Z_NULL with NULL. Fix incorrect uses of NULL/Z_NULL.
authorMika Lindqvist <postmaster@raasu.org>
Mon, 25 Apr 2016 19:59:59 +0000 (22:59 +0300)
committerHans Kristian Rosbach <hk-git@circlestorm.org>
Tue, 31 Jan 2017 09:53:22 +0000 (10:53 +0100)
15 files changed:
adler32.c
compress.c
crc32.c
deflate.c
deflate_p.h
gzread.c
gzwrite.c
infback.c
inflate.c
test/example.c
test/infcover.c
test/minigzip.c
uncompr.c
zconf.h.in
zlib.h

index 495101dd5d0c7ddd1021c1c9f6147fc47f0e9f2e..81c263948af43c3efca6ae70672fcdd4f5a1f070 100644 (file)
--- a/adler32.c
+++ b/adler32.c
@@ -80,7 +80,7 @@ uint32_t ZEXPORT adler32(uint32_t adler, const unsigned char *buf, uint32_t len)
     }
 
     /* initial Adler-32 value (deferred check for len == 1 speed) */
-    if (buf == Z_NULL)
+    if (buf == NULL)
         return 1L;
 
     /* in case short lengths are provided, keep it somewhat fast */
index 9f6f140298fc9898b8adb1704a839a499f2f5374..1fba05701145dfabaa2bfde50ab029a5a0e558a5 100644 (file)
@@ -29,8 +29,8 @@ int ZEXPORT compress2(unsigned char *dest, size_t *destLen, const unsigned char
     left = *destLen;
     *destLen = 0;
 
-    stream.zalloc = (alloc_func)0;
-    stream.zfree = (free_func)0;
+    stream.zalloc = NULL;
+    stream.zfree = NULL;
     stream.opaque = NULL;
 
     err = deflateInit(&stream, level);
diff --git a/crc32.c b/crc32.c
index 937f48d211eca109a0dfdceac7f9fd06b1f21506..433244d86538c9ed976585d3c0c40eef1159f103 100644 (file)
--- a/crc32.c
+++ b/crc32.c
@@ -212,7 +212,7 @@ const uint32_t * ZEXPORT get_crc_table(void) {
 
 /* ========================================================================= */
 uint32_t ZEXPORT crc32(uint32_t crc, const unsigned char *buf, z_off64_t len) {
-    if (buf == Z_NULL) return 0;
+    if (buf == NULL) return 0;
 
 #ifdef DYNAMIC_CRC_TABLE
     if (crc_table_empty)
index de3f7e193fb81f57773e5170b5509ea2d6ba2d01..d3661c48afda98df25f3d6a90970f6f25acb6f3f 100644 (file)
--- a/deflate.c
+++ b/deflate.c
@@ -177,18 +177,18 @@ int ZEXPORT deflateInit2_(z_stream *strm, int level, int method, int windowBits,
     x86_check_features();
 #endif
 
-    if (version == Z_NULL || version[0] != my_version[0] || stream_size != sizeof(z_stream)) {
+    if (version == NULL || version[0] != my_version[0] || stream_size != sizeof(z_stream)) {
         return Z_VERSION_ERROR;
     }
-    if (strm == Z_NULL)
+    if (strm == NULL)
         return Z_STREAM_ERROR;
 
-    strm->msg = Z_NULL;
-    if (strm->zalloc == (alloc_func)0) {
+    strm->msg = NULL;
+    if (strm->zalloc == NULL) {
         strm->zalloc = zcalloc;
         strm->opaque = NULL;
     }
-    if (strm->zfree == (free_func)0)
+    if (strm->zfree == NULL)
         strm->zfree = zcfree;
 
     if (level == Z_DEFAULT_COMPRESSION)
@@ -216,13 +216,13 @@ int ZEXPORT deflateInit2_(z_stream *strm, int level, int method, int windowBits,
 #endif
 
     s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state));
-    if (s == Z_NULL)
+    if (s == NULL)
         return Z_MEM_ERROR;
     strm->state = (struct internal_state *)s;
     s->strm = strm;
 
     s->wrap = wrap;
-    s->gzhead = Z_NULL;
+    s->gzhead = NULL;
     s->w_bits = windowBits;
     s->w_size = 1 << s->w_bits;
     s->w_mask = s->w_size - 1;
@@ -254,8 +254,8 @@ int ZEXPORT deflateInit2_(z_stream *strm, int level, int method, int windowBits,
     s->pending_buf = (unsigned char *) overlay;
     s->pending_buf_size = (unsigned long)s->lit_bufsize * (sizeof(uint16_t)+2L);
 
-    if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
-        s->pending_buf == Z_NULL) {
+    if (s->window == NULL || s->prev == NULL || s->head == NULL ||
+        s->pending_buf == NULL) {
         s->status = FINISH_STATE;
         strm->msg = ERR_MSG(Z_MEM_ERROR);
         deflateEnd(strm);
@@ -279,7 +279,7 @@ int ZEXPORT deflateSetDictionary(z_stream *strm, const unsigned char *dictionary
     uint32_t avail;
     const unsigned char *next;
 
-    if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL)
+    if (strm == NULL || strm->state == NULL || dictionary == NULL)
         return Z_STREAM_ERROR;
     s = strm->state;
     wrap = s->wrap;
@@ -333,12 +333,12 @@ int ZEXPORT deflateSetDictionary(z_stream *strm, const unsigned char *dictionary
 int ZEXPORT deflateResetKeep(z_stream *strm) {
     deflate_state *s;
 
-    if (strm == Z_NULL || strm->state == Z_NULL || strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) {
+    if (strm == NULL || strm->state == NULL || strm->zalloc == NULL || strm->zfree == NULL) {
         return Z_STREAM_ERROR;
     }
 
     strm->total_in = strm->total_out = 0;
-    strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */
+    strm->msg = NULL; /* use zfree if we ever allocate msg dynamically */
     strm->data_type = Z_UNKNOWN;
 
     s = (deflate_state *)strm->state;
@@ -350,9 +350,9 @@ int ZEXPORT deflateResetKeep(z_stream *strm) {
     }
     s->status = s->wrap ? INIT_STATE : BUSY_STATE;
 #ifdef GZIP
-    strm->adler = s->wrap == 2 ? crc32(0L, Z_NULL, 0) : adler32(0L, Z_NULL, 0);
+    strm->adler = s->wrap == 2 ? crc32(0L, NULL, 0) : adler32(0L, NULL, 0);
 #else
-    strm->adler = adler32(0L, Z_NULL, 0);
+    strm->adler = adler32(0L, NULL, 0);
 #endif
     s->last_flush = Z_NO_FLUSH;
 
@@ -373,7 +373,7 @@ int ZEXPORT deflateReset(z_stream *strm) {
 
 /* ========================================================================= */
 int ZEXPORT deflateSetHeader(z_stream *strm, gz_headerp head) {
-    if (strm == Z_NULL || strm->state == Z_NULL)
+    if (strm == NULL || strm->state == NULL)
         return Z_STREAM_ERROR;
     if (strm->state->wrap != 2)
         return Z_STREAM_ERROR;
@@ -383,11 +383,11 @@ int ZEXPORT deflateSetHeader(z_stream *strm, gz_headerp head) {
 
 /* ========================================================================= */
 int ZEXPORT deflatePending(z_stream *strm, uint32_t *pending, int *bits) {
-    if (strm == Z_NULL || strm->state == Z_NULL)
+    if (strm == NULL || strm->state == NULL)
         return Z_STREAM_ERROR;
-    if (pending != Z_NULL)
+    if (pending != NULL)
         *pending = strm->state->pending;
-    if (bits != Z_NULL)
+    if (bits != NULL)
         *bits = strm->state->bi_valid;
     return Z_OK;
 }
@@ -397,7 +397,7 @@ int ZEXPORT deflatePrime(z_stream *strm, int bits, int value) {
     deflate_state *s;
     int put;
 
-    if (strm == Z_NULL || strm->state == Z_NULL)
+    if (strm == NULL || strm->state == NULL)
         return Z_STREAM_ERROR;
     s = strm->state;
     if ((unsigned char *)(s->d_buf) < s->pending_out + ((Buf_size + 7) >> 3))
@@ -421,7 +421,7 @@ int ZEXPORT deflateParams(z_stream *strm, int level, int strategy) {
     compress_func func;
     int err = Z_OK;
 
-    if (strm == Z_NULL || strm->state == Z_NULL)
+    if (strm == NULL || strm->state == NULL)
         return Z_STREAM_ERROR;
     s = strm->state;
 
@@ -453,7 +453,7 @@ int ZEXPORT deflateParams(z_stream *strm, int level, int strategy) {
 int ZEXPORT deflateTune(z_stream *strm, int good_length, int max_lazy, int nice_length, int max_chain) {
     deflate_state *s;
 
-    if (strm == Z_NULL || strm->state == Z_NULL)
+    if (strm == NULL || strm->state == NULL)
         return Z_STREAM_ERROR;
     s = strm->state;
     s->good_match = good_length;
@@ -489,7 +489,7 @@ unsigned long ZEXPORT deflateBound(z_stream *strm, unsigned long sourceLen) {
     complen = sourceLen + ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 5;
 
     /* if can't get parameters, return conservative bound plus zlib wrapper */
-    if (strm == Z_NULL || strm->state == Z_NULL)
+    if (strm == NULL || strm->state == NULL)
         return complen + 6;
 
     /* compute wrapper length */
@@ -503,18 +503,18 @@ unsigned long ZEXPORT deflateBound(z_stream *strm, unsigned long sourceLen) {
         break;
     case 2:                                 /* gzip wrapper */
         wraplen = 18;
-        if (s->gzhead != Z_NULL) {          /* user-supplied gzip header */
-            if (s->gzhead->extra != Z_NULL) {
+        if (s->gzhead != NULL) {            /* user-supplied gzip header */
+            if (s->gzhead->extra != NULL) {
                 wraplen += 2 + s->gzhead->extra_len;
             }
             str = s->gzhead->name;
-            if (str != Z_NULL) {
+            if (str != NULL) {
                 do {
                     wraplen++;
                 } while (*str++);
             }
             str = s->gzhead->comment;
-            if (str != Z_NULL) {
+            if (str != NULL) {
                 do {
                     wraplen++;
                 } while (*str++);
@@ -578,12 +578,12 @@ int ZEXPORT deflate(z_stream *strm, int flush) {
     int old_flush; /* value of flush param for previous deflate call */
     deflate_state *s;
 
-    if (strm == Z_NULL || strm->state == Z_NULL || flush > Z_BLOCK || flush < 0) {
+    if (strm == NULL || strm->state == NULL || flush > Z_BLOCK || flush < 0) {
         return Z_STREAM_ERROR;
     }
     s = strm->state;
 
-    if (strm->next_out == Z_NULL || (strm->avail_in != 0 && strm->next_in == Z_NULL) ||
+    if (strm->next_out == NULL || (strm->avail_in != 0 && strm->next_in == NULL) ||
         (s->status == FINISH_STATE && flush != Z_FINISH)) {
         ERR_RETURN(strm, Z_STREAM_ERROR);
     }
@@ -602,7 +602,7 @@ int ZEXPORT deflate(z_stream *strm, int flush) {
             put_byte(s, 31);
             put_byte(s, 139);
             put_byte(s, 8);
-            if (s->gzhead == Z_NULL) {
+            if (s->gzhead == NULL) {
                 put_byte(s, 0);
                 put_byte(s, 0);
                 put_byte(s, 0);
@@ -616,9 +616,9 @@ int ZEXPORT deflate(z_stream *strm, int flush) {
             } else {
                 put_byte(s, (s->gzhead->text ? 1 : 0) +
                             (s->gzhead->hcrc ? 2 : 0) +
-                            (s->gzhead->extra == Z_NULL ? 0 : 4) +
-                            (s->gzhead->name == Z_NULL ? 0 : 8) +
-                            (s->gzhead->comment == Z_NULL ? 0 : 16) );
+                            (s->gzhead->extra == NULL ? 0 : 4) +
+                            (s->gzhead->name == NULL ? 0 : 8) +
+                            (s->gzhead->comment == NULL ? 0 : 16) );
                 put_byte(s, (unsigned char)(s->gzhead->time & 0xff));
                 put_byte(s, (unsigned char)((s->gzhead->time >> 8) & 0xff));
                 put_byte(s, (unsigned char)((s->gzhead->time >> 16) & 0xff));
@@ -627,7 +627,7 @@ int ZEXPORT deflate(z_stream *strm, int flush) {
                             (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
                              4 : 0));
                 put_byte(s, s->gzhead->os & 0xff);
-                if (s->gzhead->extra != Z_NULL) {
+                if (s->gzhead->extra != NULL) {
                     put_byte(s, s->gzhead->extra_len & 0xff);
                     put_byte(s, (s->gzhead->extra_len >> 8) & 0xff);
                 }
@@ -663,12 +663,12 @@ int ZEXPORT deflate(z_stream *strm, int flush) {
                 putShortMSB(s, (uint16_t)(strm->adler >> 16));
                 putShortMSB(s, (uint16_t)strm->adler);
             }
-            strm->adler = adler32(0L, Z_NULL, 0);
+            strm->adler = adler32(0L, NULL, 0);
         }
     }
 #ifdef GZIP
     if (s->status == EXTRA_STATE) {
-        if (s->gzhead->extra != Z_NULL) {
+        if (s->gzhead->extra != NULL) {
             uint32_t beg = s->pending;  /* start of bytes to update crc */
 
             while (s->gzindex < (s->gzhead->extra_len & 0xffff)) {
@@ -694,7 +694,7 @@ int ZEXPORT deflate(z_stream *strm, int flush) {
         }
     }
     if (s->status == NAME_STATE) {
-        if (s->gzhead->name != Z_NULL) {
+        if (s->gzhead->name != NULL) {
             uint32_t beg = s->pending;  /* start of bytes to update crc */
             int val;
 
@@ -723,7 +723,7 @@ int ZEXPORT deflate(z_stream *strm, int flush) {
         }
     }
     if (s->status == COMMENT_STATE) {
-        if (s->gzhead->comment != Z_NULL) {
+        if (s->gzhead->comment != NULL) {
             uint32_t beg = s->pending;  /* start of bytes to update crc */
             int val;
 
@@ -756,7 +756,7 @@ int ZEXPORT deflate(z_stream *strm, int flush) {
             if (s->pending + 2 <= s->pending_buf_size) {
                 put_byte(s, (unsigned char)(strm->adler & 0xff));
                 put_byte(s, (unsigned char)((strm->adler >> 8) & 0xff));
-                strm->adler = crc32(0L, Z_NULL, 0);
+                strm->adler = crc32(0L, NULL, 0);
                 s->status = BUSY_STATE;
             }
         } else {
@@ -884,7 +884,7 @@ int ZEXPORT deflate(z_stream *strm, int flush) {
 int ZEXPORT deflateEnd(z_stream *strm) {
     int status;
 
-    if (strm == Z_NULL || strm->state == Z_NULL)
+    if (strm == NULL || strm->state == NULL)
         return Z_STREAM_ERROR;
 
     status = strm->state->status;
@@ -905,7 +905,7 @@ int ZEXPORT deflateEnd(z_stream *strm) {
     TRY_FREE(strm, strm->state->window);
 
     ZFREE(strm, strm->state);
-    strm->state = Z_NULL;
+    strm->state = NULL;
 
     return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK;
 }
@@ -918,7 +918,7 @@ int ZEXPORT deflateCopy(z_stream *dest, z_stream *source) {
     deflate_state *ss;
     uint16_t *overlay;
 
-    if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) {
+    if (source == NULL || dest == NULL || source->state == NULL) {
         return Z_STREAM_ERROR;
     }
 
@@ -927,7 +927,7 @@ int ZEXPORT deflateCopy(z_stream *dest, z_stream *source) {
     memcpy((void *)dest, (void *)source, sizeof(z_stream));
 
     ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));
-    if (ds == Z_NULL)
+    if (ds == NULL)
         return Z_MEM_ERROR;
     dest->state = (struct internal_state *) ds;
     memcpy((void *)ds, (void *)ss, sizeof(deflate_state));
@@ -939,7 +939,7 @@ int ZEXPORT deflateCopy(z_stream *dest, z_stream *source) {
     overlay = (uint16_t *) ZALLOC(dest, ds->lit_bufsize, sizeof(uint16_t)+2);
     ds->pending_buf = (unsigned char *) overlay;
 
-    if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL || ds->pending_buf == Z_NULL) {
+    if (ds->window == NULL || ds->prev == NULL || ds->head == NULL || ds->pending_buf == NULL) {
         deflateEnd(dest);
         return Z_MEM_ERROR;
     }
index 8965980551112f08a563a28f621b238a031f2b71..67dc6eb701b90a2dc5db78c1d8fd53fc2d32d71f 100644 (file)
@@ -66,7 +66,7 @@ static inline Pos insert_string(deflate_state *const s, const Pos str, uInt coun
 #define FLUSH_BLOCK_ONLY(s, last) { \
     _tr_flush_block(s, (s->block_start >= 0L ? \
                    (char *)&s->window[(unsigned)s->block_start] : \
-                   (char *)Z_NULL), \
+                   NULL), \
                    (ulg)((long)s->strstart - s->block_start), \
                    (last)); \
     s->block_start = s->strstart; \
index 140553336f0441de98e97015ea72c468e4102c62..970b64917b6a3b691e835b426b90460afa4a2c4a 100644 (file)
--- a/gzread.c
+++ b/gzread.c
@@ -94,11 +94,11 @@ static int gz_look(gz_statep state) {
         state->size = state->want;
 
         /* allocate inflate memory */
-        state->strm.zalloc = Z_NULL;
-        state->strm.zfree = Z_NULL;
-        state->strm.opaque = Z_NULL;
+        state->strm.zalloc = NULL;
+        state->strm.zfree = NULL;
+        state->strm.opaque = NULL;
         state->strm.avail_in = 0;
-        state->strm.next_in = Z_NULL;
+        state->strm.next_in = NULL;
         if (inflateInit2(&(state->strm), 15 + 16) != Z_OK) {    /* gunzip */
             free(state->out);
             free(state->in);
index f84ec18d1c26ba600120c3aa468b0845282afb73..e4860342a267656e22bb6f508a750495c59ada32 100644 (file)
--- a/gzwrite.c
+++ b/gzwrite.c
@@ -35,9 +35,9 @@ static int gz_init(gz_statep state) {
         }
 
         /* allocate deflate memory, set up for gzip compression */
-        strm->zalloc = Z_NULL;
-        strm->zfree = Z_NULL;
-        strm->opaque = Z_NULL;
+        strm->zalloc = NULL;
+        strm->zfree = NULL;
+        strm->opaque = NULL;
         ret = deflateInit2(strm, state->level, Z_DEFLATED, MAX_WBITS + 16, DEF_MEM_LEVEL, state->strategy);
         if (ret != Z_OK) {
             free(state->out);
index 01b782f568c2c11ec6b509033f83a3a1d4271577..4fc783fd31f2256f14310ffa52f1dc861beac2dc 100644 (file)
--- a/infback.c
+++ b/infback.c
@@ -20,7 +20,7 @@ static void fixedtables(struct inflate_state *state);
 
 /*
    strm provides memory allocation functions in zalloc and zfree, or
-   Z_NULL to use the library memory allocation functions.
+   NULL to use the library memory allocation functions.
 
    windowBits is in the range 8..15, and window is a user-supplied
    window and output buffer that is 2**windowBits bytes.
@@ -29,19 +29,19 @@ int ZEXPORT inflateBackInit_(z_stream *strm, int windowBits, unsigned char *wind
                               const char *version, int stream_size) {
     struct inflate_state *state;
 
-    if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || stream_size != (int)(sizeof(z_stream)))
+    if (version == NULL || version[0] != ZLIB_VERSION[0] || stream_size != (int)(sizeof(z_stream)))
         return Z_VERSION_ERROR;
-    if (strm == Z_NULL || window == Z_NULL || windowBits < 8 || windowBits > 15)
+    if (strm == NULL || window == NULL || windowBits < 8 || windowBits > 15)
         return Z_STREAM_ERROR;
-    strm->msg = Z_NULL;                 /* in case we return an error */
-    if (strm->zalloc == (alloc_func)0) {
+    strm->msg = NULL;                   /* in case we return an error */
+    if (strm->zalloc == NULL) {
         strm->zalloc = zcalloc;
         strm->opaque = NULL;
     }
-    if (strm->zfree == (free_func)0)
+    if (strm->zfree == NULL)
         strm->zfree = zcfree;
     state = (struct inflate_state *)ZALLOC(strm, 1, sizeof(struct inflate_state));
-    if (state == Z_NULL)
+    if (state == NULL)
         return Z_MEM_ERROR;
     Tracev((stderr, "inflate: allocated\n"));
     strm->state = (struct internal_state *)state;
@@ -143,7 +143,7 @@ static void fixedtables(struct inflate_state *state) {
         if (have == 0) { \
             have = in(in_desc, &next); \
             if (have == 0) { \
-                next = Z_NULL; \
+                next = NULL; \
                 ret = Z_BUF_ERROR; \
                 goto inf_leave; \
             } \
@@ -223,12 +223,12 @@ static void fixedtables(struct inflate_state *state) {
 
    in() should return zero on failure.  out() should return non-zero on
    failure.  If either in() or out() fails, than inflateBack() returns a
-   Z_BUF_ERROR.  strm->next_in can be checked for Z_NULL to see whether it
+   Z_BUF_ERROR.  strm->next_in can be checked for NULL to see whether it
    was in() or out() that caused in the error.  Otherwise,  inflateBack()
    returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format
    error, or Z_MEM_ERROR if it could not allocate memory for the state.
    inflateBack() can also return Z_STREAM_ERROR if the input parameters
-   are not correct, i.e. strm is Z_NULL or the state was not initialized.
+   are not correct, i.e. strm is NULL or the state was not initialized.
  */
 int ZEXPORT inflateBack(z_stream *strm, in_func in, void *in_desc, out_func out, void *out_desc) {
     struct inflate_state *state;
@@ -247,17 +247,17 @@ int ZEXPORT inflateBack(z_stream *strm, in_func in, void *in_desc, out_func out,
         {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
 
     /* Check that the strm exists and that the state was initialized */
-    if (strm == Z_NULL || strm->state == Z_NULL)
+    if (strm == NULL || strm->state == NULL)
         return Z_STREAM_ERROR;
     state = (struct inflate_state *)strm->state;
 
     /* Reset the state */
-    strm->msg = Z_NULL;
+    strm->msg = NULL;
     state->mode = TYPE;
     state->last = 0;
     state->whave = 0;
     next = strm->next_in;
-    have = next != Z_NULL ? strm->avail_in : 0;
+    have = next != NULL ? strm->avail_in : 0;
     hold = 0;
     bits = 0;
     put = state->window;
@@ -603,10 +603,10 @@ int ZEXPORT inflateBack(z_stream *strm, in_func in, void *in_desc, out_func out,
 }
 
 int ZEXPORT inflateBackEnd(z_stream *strm) {
-    if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
+    if (strm == NULL || strm->state == NULL || strm->zfree == NULL)
         return Z_STREAM_ERROR;
     ZFREE(strm, strm->state);
-    strm->state = Z_NULL;
+    strm->state = NULL;
     Tracev((stderr, "inflate: end\n"));
     return Z_OK;
 }
index 3ea438702b19b9f1490828c28440bb10b8e2bd1c..a2ccfbf99b3381fed4ad7a3ec91e18efcd7aeff7 100644 (file)
--- a/inflate.c
+++ b/inflate.c
@@ -102,18 +102,18 @@ static uint32_t syncsearch(uint32_t *have, const unsigned char *buf, uint32_t le
 int ZEXPORT inflateResetKeep(z_stream *strm) {
     struct inflate_state *state;
 
-    if (strm == Z_NULL || strm->state == Z_NULL)
+    if (strm == NULL || strm->state == NULL)
         return Z_STREAM_ERROR;
     state = (struct inflate_state *)strm->state;
     strm->total_in = strm->total_out = state->total = 0;
-    strm->msg = Z_NULL;
+    strm->msg = NULL;
     if (state->wrap)        /* to support ill-conceived Java test suite */
         strm->adler = state->wrap & 1;
     state->mode = HEAD;
     state->last = 0;
     state->havedict = 0;
     state->dmax = 32768U;
-    state->head = Z_NULL;
+    state->head = NULL;
     state->hold = 0;
     state->bits = 0;
     state->lencode = state->distcode = state->next = state->codes;
@@ -126,7 +126,7 @@ int ZEXPORT inflateResetKeep(z_stream *strm) {
 int ZEXPORT inflateReset(z_stream *strm) {
     struct inflate_state *state;
 
-    if (strm == Z_NULL || strm->state == Z_NULL)
+    if (strm == NULL || strm->state == NULL)
         return Z_STREAM_ERROR;
     state = (struct inflate_state *)strm->state;
     state->wsize = 0;
@@ -140,7 +140,7 @@ int ZEXPORT inflateReset2(z_stream *strm, int windowBits) {
     struct inflate_state *state;
 
     /* get the state */
-    if (strm == Z_NULL || strm->state == Z_NULL)
+    if (strm == NULL || strm->state == NULL)
         return Z_STREAM_ERROR;
     state = (struct inflate_state *)strm->state;
 
@@ -159,9 +159,9 @@ int ZEXPORT inflateReset2(z_stream *strm, int windowBits) {
     /* set number of window bits, free window if different */
     if (windowBits && (windowBits < 8 || windowBits > 15))
         return Z_STREAM_ERROR;
-    if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) {
+    if (state->window != NULL && state->wbits != (unsigned)windowBits) {
         ZFREE(strm, state->window);
-        state->window = Z_NULL;
+        state->window = NULL;
     }
 
     /* update state and reset the rest of it */
@@ -174,27 +174,27 @@ int ZEXPORT inflateInit2_(z_stream *strm, int windowBits, const char *version, i
     int ret;
     struct inflate_state *state;
 
-    if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || stream_size != (int)(sizeof(z_stream)))
+    if (version == NULL || version[0] != ZLIB_VERSION[0] || stream_size != (int)(sizeof(z_stream)))
         return Z_VERSION_ERROR;
-    if (strm == Z_NULL)
+    if (strm == NULL)
         return Z_STREAM_ERROR;
-    strm->msg = Z_NULL;                 /* in case we return an error */
-    if (strm->zalloc == (alloc_func)0) {
+    strm->msg = NULL;                   /* in case we return an error */
+    if (strm->zalloc == NULL) {
         strm->zalloc = zcalloc;
         strm->opaque = NULL;
     }
-    if (strm->zfree == (free_func)0)
+    if (strm->zfree == NULL)
         strm->zfree = zcfree;
     state = (struct inflate_state *) ZALLOC(strm, 1, sizeof(struct inflate_state));
-    if (state == Z_NULL)
+    if (state == NULL)
         return Z_MEM_ERROR;
     Tracev((stderr, "inflate: allocated\n"));
     strm->state = (struct internal_state *)state;
-    state->window = Z_NULL;
+    state->window = NULL;
     ret = inflateReset2(strm, windowBits);
     if (ret != Z_OK) {
         ZFREE(strm, state);
-        strm->state = Z_NULL;
+        strm->state = NULL;
     }
     return ret;
 }
@@ -206,7 +206,7 @@ int ZEXPORT inflateInit_(z_stream *strm, const char *version, int stream_size) {
 int ZEXPORT inflatePrime(z_stream *strm, int bits, int value) {
     struct inflate_state *state;
 
-    if (strm == Z_NULL || strm->state == Z_NULL)
+    if (strm == NULL || strm->state == NULL)
         return Z_STREAM_ERROR;
     state = (struct inflate_state *)strm->state;
     if (bits < 0) {
@@ -357,9 +357,9 @@ static int updatewindow(z_stream *strm, const unsigned char *end, uint32_t copy)
     state = (struct inflate_state *)strm->state;
 
     /* if it hasn't been done already, allocate space for the window */
-    if (state->window == Z_NULL) {
+    if (state->window == NULL) {
         state->window = (unsigned char *) ZALLOC(strm, 1U << state->wbits, sizeof(unsigned char));
-        if (state->window == Z_NULL)
+        if (state->window == NULL)
             return 1;
     }
 
@@ -592,8 +592,8 @@ int ZEXPORT inflate(z_stream *strm, int flush) {
     static const uint16_t order[19] = /* permutation of code lengths */
         {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
 
-    if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL ||
-        (strm->next_in == Z_NULL && strm->avail_in != 0))
+    if (strm == NULL || strm->state == NULL || strm->next_out == NULL ||
+        (strm->next_in == NULL && strm->avail_in != 0))
         return Z_STREAM_ERROR;
 
     state = (struct inflate_state *)strm->state;
@@ -615,14 +615,14 @@ int ZEXPORT inflate(z_stream *strm, int flush) {
             if ((state->wrap & 2) && hold == 0x8b1f) {  /* gzip header */
                 if (state->wbits == 0)
                     state->wbits = 15;
-                state->check = crc32(0L, Z_NULL, 0);
+                state->check = crc32(0L, NULL, 0);
                 CRC2(state->check, hold);
                 INITBITS();
                 state->mode = FLAGS;
                 break;
             }
             state->flags = 0;           /* expect zlib header */
-            if (state->head != Z_NULL)
+            if (state->head != NULL)
                 state->head->done = -1;
             if (!(state->wrap & 1) ||   /* check if zlib header allowed */
 #else
@@ -649,7 +649,7 @@ int ZEXPORT inflate(z_stream *strm, int flush) {
             }
             state->dmax = 1U << len;
             Tracev((stderr, "inflate:   zlib header ok\n"));
-            strm->adler = state->check = adler32(0L, Z_NULL, 0);
+            strm->adler = state->check = adler32(0L, NULL, 0);
             state->mode = hold & 0x200 ? DICTID : TYPE;
             INITBITS();
             break;
@@ -667,7 +667,7 @@ int ZEXPORT inflate(z_stream *strm, int flush) {
                 state->mode = BAD;
                 break;
             }
-            if (state->head != Z_NULL)
+            if (state->head != NULL)
                 state->head->text = (int)((hold >> 8) & 1);
             if (state->flags & 0x0200)
                 CRC2(state->check, hold);
@@ -675,7 +675,7 @@ int ZEXPORT inflate(z_stream *strm, int flush) {
             state->mode = TIME;
         case TIME:
             NEEDBITS(32);
-            if (state->head != Z_NULL)
+            if (state->head != NULL)
                 state->head->time = hold;
             if (state->flags & 0x0200)
                 CRC4(state->check, hold);
@@ -683,7 +683,7 @@ int ZEXPORT inflate(z_stream *strm, int flush) {
             state->mode = OS;
         case OS:
             NEEDBITS(16);
-            if (state->head != Z_NULL) {
+            if (state->head != NULL) {
                 state->head->xflags = (int)(hold & 0xff);
                 state->head->os = (int)(hold >> 8);
             }
@@ -695,13 +695,13 @@ int ZEXPORT inflate(z_stream *strm, int flush) {
             if (state->flags & 0x0400) {
                 NEEDBITS(16);
                 state->length = (uint16_t)hold;
-                if (state->head != Z_NULL)
+                if (state->head != NULL)
                     state->head->extra_len = (uint16_t)hold;
                 if (state->flags & 0x0200)
                     CRC2(state->check, hold);
                 INITBITS();
-            } else if (state->head != Z_NULL) {
-                state->head->extra = Z_NULL;
+            } else if (state->head != NULL) {
+                state->head->extra = NULL;
             }
             state->mode = EXTRA;
         case EXTRA:
@@ -710,8 +710,8 @@ int ZEXPORT inflate(z_stream *strm, int flush) {
                 if (copy > have)
                     copy = have;
                 if (copy) {
-                    if (state->head != Z_NULL &&
-                        state->head->extra != Z_NULL) {
+                    if (state->head != NULL &&
+                        state->head->extra != NULL) {
                         len = state->head->extra_len - state->length;
                         memcpy(state->head->extra + len, next,
                                 len + copy > state->head->extra_max ?
@@ -734,7 +734,7 @@ int ZEXPORT inflate(z_stream *strm, int flush) {
                 copy = 0;
                 do {
                     len = (unsigned)(next[copy++]);
-                    if (state->head != Z_NULL && state->head->name != Z_NULL && state->length < state->head->name_max)
+                    if (state->head != NULL && state->head->name != NULL && state->length < state->head->name_max)
                         state->head->name[state->length++] = len;
                 } while (len && copy < have);
                 if (state->flags & 0x0200)
@@ -743,8 +743,8 @@ int ZEXPORT inflate(z_stream *strm, int flush) {
                 next += copy;
                 if (len)
                     goto inf_leave;
-            } else if (state->head != Z_NULL) {
-                state->head->name = Z_NULL;
+            } else if (state->head != NULL) {
+                state->head->name = NULL;
             }
             state->length = 0;
             state->mode = COMMENT;
@@ -754,7 +754,7 @@ int ZEXPORT inflate(z_stream *strm, int flush) {
                 copy = 0;
                 do {
                     len = (unsigned)(next[copy++]);
-                    if (state->head != Z_NULL && state->head->comment != Z_NULL
+                    if (state->head != NULL && state->head->comment != NULL
                         && state->length < state->head->comm_max)
                         state->head->comment[state->length++] = len;
                 } while (len && copy < have);
@@ -764,8 +764,8 @@ int ZEXPORT inflate(z_stream *strm, int flush) {
                 next += copy;
                 if (len)
                     goto inf_leave;
-            } else if (state->head != Z_NULL) {
-                state->head->comment = Z_NULL;
+            } else if (state->head != NULL) {
+                state->head->comment = NULL;
             }
             state->mode = HCRC;
         case HCRC:
@@ -778,11 +778,11 @@ int ZEXPORT inflate(z_stream *strm, int flush) {
                 }
                 INITBITS();
             }
-            if (state->head != Z_NULL) {
+            if (state->head != NULL) {
                 state->head->hcrc = (int)((state->flags >> 9) & 1);
                 state->head->done = 1;
             }
-            strm->adler = state->check = crc32(0L, Z_NULL, 0);
+            strm->adler = state->check = crc32(0L, NULL, 0);
             state->mode = TYPE;
             break;
 #endif
@@ -796,7 +796,7 @@ int ZEXPORT inflate(z_stream *strm, int flush) {
                 RESTORE();
                 return Z_NEED_DICT;
             }
-            strm->adler = state->check = adler32(0L, Z_NULL, 0);
+            strm->adler = state->check = adler32(0L, NULL, 0);
             state->mode = TYPE;
         case TYPE:
             if (flush == Z_BLOCK || flush == Z_TREES)
@@ -1228,13 +1228,13 @@ int ZEXPORT inflate(z_stream *strm, int flush) {
 
 int ZEXPORT inflateEnd(z_stream *strm) {
     struct inflate_state *state;
-    if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
+    if (strm == NULL || strm->state == NULL || strm->zfree == NULL)
         return Z_STREAM_ERROR;
     state = (struct inflate_state *)strm->state;
-    if (state->window != Z_NULL)
+    if (state->window != NULL)
         ZFREE(strm, state->window);
     ZFREE(strm, strm->state);
-    strm->state = Z_NULL;
+    strm->state = NULL;
     Tracev((stderr, "inflate: end\n"));
     return Z_OK;
 }
@@ -1243,16 +1243,16 @@ int ZEXPORT inflateGetDictionary(z_stream *strm, unsigned char *dictionary, unsi
     struct inflate_state *state;
 
     /* check state */
-    if (strm == Z_NULL || strm->state == Z_NULL)
+    if (strm == NULL || strm->state == NULL)
         return Z_STREAM_ERROR;
     state = (struct inflate_state *)strm->state;
 
     /* copy dictionary */
-    if (state->whave && dictionary != Z_NULL) {
+    if (state->whave && dictionary != NULL) {
         memcpy(dictionary, state->window + state->wnext, state->whave - state->wnext);
         memcpy(dictionary + state->whave - state->wnext, state->window, state->wnext);
     }
-    if (dictLength != Z_NULL)
+    if (dictLength != NULL)
         *dictLength = state->whave;
     return Z_OK;
 }
@@ -1263,7 +1263,7 @@ int ZEXPORT inflateSetDictionary(z_stream *strm, const unsigned char *dictionary
     int ret;
 
     /* check state */
-    if (strm == Z_NULL || strm->state == Z_NULL)
+    if (strm == NULL || strm->state == NULL)
         return Z_STREAM_ERROR;
     state = (struct inflate_state *)strm->state;
     if (state->wrap != 0 && state->mode != DICT)
@@ -1271,7 +1271,7 @@ int ZEXPORT inflateSetDictionary(z_stream *strm, const unsigned char *dictionary
 
     /* check for correct dictionary identifier */
     if (state->mode == DICT) {
-        dictid = adler32(0L, Z_NULL, 0);
+        dictid = adler32(0L, NULL, 0);
         dictid = adler32(dictid, dictionary, dictLength);
         if (dictid != state->check)
             return Z_DATA_ERROR;
@@ -1293,7 +1293,7 @@ int ZEXPORT inflateGetHeader(z_stream *strm, gz_headerp head) {
     struct inflate_state *state;
 
     /* check state */
-    if (strm == Z_NULL || strm->state == Z_NULL)
+    if (strm == NULL || strm->state == NULL)
         return Z_STREAM_ERROR;
     state = (struct inflate_state *)strm->state;
     if ((state->wrap & 2) == 0)
@@ -1342,7 +1342,7 @@ int ZEXPORT inflateSync(z_stream *strm) {
     struct inflate_state *state;
 
     /* check parameters */
-    if (strm == Z_NULL || strm->state == Z_NULL)
+    if (strm == NULL || strm->state == NULL)
         return Z_STREAM_ERROR;
     state = (struct inflate_state *)strm->state;
     if (strm->avail_in == 0 && state->bits < 8)
@@ -1392,7 +1392,7 @@ int ZEXPORT inflateSync(z_stream *strm) {
 int ZEXPORT inflateSyncPoint(z_stream *strm) {
     struct inflate_state *state;
 
-    if (strm == Z_NULL || strm->state == Z_NULL)
+    if (strm == NULL || strm->state == NULL)
         return Z_STREAM_ERROR;
     state = (struct inflate_state *)strm->state;
     return state->mode == STORED && state->bits == 0;
@@ -1405,20 +1405,20 @@ int ZEXPORT inflateCopy(z_stream *dest, z_stream *source) {
     unsigned wsize;
 
     /* check input */
-    if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL ||
-        source->zalloc == (alloc_func)0 || source->zfree == (free_func)0)
+    if (dest == NULL || source == NULL || source->state == NULL ||
+        source->zalloc == NULL || source->zfree == NULL)
         return Z_STREAM_ERROR;
     state = (struct inflate_state *)source->state;
 
     /* allocate space */
     copy = (struct inflate_state *)
            ZALLOC(source, 1, sizeof(struct inflate_state));
-    if (copy == Z_NULL)
+    if (copy == NULL)
         return Z_MEM_ERROR;
-    window = Z_NULL;
-    if (state->window != Z_NULL) {
+    window = NULL;
+    if (state->window != NULL) {
         window = (unsigned char *) ZALLOC(source, 1U << state->wbits, sizeof(unsigned char));
-        if (window == Z_NULL) {
+        if (window == NULL) {
             ZFREE(source, copy);
             return Z_MEM_ERROR;
         }
@@ -1432,7 +1432,7 @@ int ZEXPORT inflateCopy(z_stream *dest, z_stream *source) {
         copy->distcode = copy->codes + (state->distcode - state->codes);
     }
     copy->next = copy->codes + (state->next - state->codes);
-    if (window != Z_NULL) {
+    if (window != NULL) {
         wsize = 1U << state->wbits;
         memcpy(window, state->window, wsize);
     }
@@ -1444,7 +1444,7 @@ int ZEXPORT inflateCopy(z_stream *dest, z_stream *source) {
 int ZEXPORT inflateUndermine(z_stream *strm, int subvert) {
     struct inflate_state *state;
 
-    if (strm == Z_NULL || strm->state == Z_NULL)
+    if (strm == NULL || strm->state == NULL)
         return Z_STREAM_ERROR;
     state = (struct inflate_state *)strm->state;
 #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
@@ -1459,7 +1459,7 @@ int ZEXPORT inflateUndermine(z_stream *strm, int subvert) {
 long ZEXPORT inflateMark(z_stream *strm) {
     struct inflate_state *state;
 
-    if (strm == Z_NULL || strm->state == Z_NULL)
+    if (strm == NULL || strm->state == NULL)
         return -1L << 16;
     state = (struct inflate_state *)strm->state;
     return ((long)(state->back) << 16) + (state->mode == COPY ? state->length :
index 43d1a16cbe0a0291f710f5c67e4312889aef6ea3..6d9bad35d191d43fc10f142a3414d510e836ef59 100644 (file)
@@ -40,8 +40,8 @@ void test_dict_inflate  (unsigned char *compr, size_t comprLen, unsigned char *u
 int  main               (int argc, char *argv[]);
 
 
-static alloc_func zalloc = (alloc_func)0;
-static free_func zfree = (free_func)0;
+static alloc_func zalloc = NULL;
+static free_func zfree = NULL;
 
 void test_compress      (unsigned char *compr, size_t comprLen,
                             unsigned char *uncompr, size_t uncomprLen);
@@ -512,7 +512,7 @@ int main(int argc, char *argv[])
     /* compr and uncompr are cleared to avoid reading uninitialized
      * data and to ensure that uncompr compresses well.
      */
-    if (compr == Z_NULL || uncompr == Z_NULL) {
+    if (compr == NULL || uncompr == NULL) {
         printf("out of memory\n");
         exit(1);
     }
index 5555a155fc3213d642f880036dfd2d52556e3d9e..ee8463651646ad9ee1027694807e44c679cf77ba 100644 (file)
@@ -45,7 +45,7 @@
                             allocated, then "msg" and information about the
                             problem is printed to stderr.  If everything is
                             normal, nothing is printed. mem_done resets the
-                            strm members to Z_NULL to use the default memory
+                            strm members to NULL to use the default memory
                             allocation routines on the next zlib initialization
                             using strm.
  */
@@ -226,9 +226,9 @@ static void mem_done(z_stream *strm, char *prefix)
 
     /* free the zone and delete from the stream */
     free(zone);
-    strm->opaque = Z_NULL;
-    strm->zalloc = Z_NULL;
-    strm->zfree = Z_NULL;
+    strm->opaque = NULL;
+    strm->zalloc = NULL;
+    strm->zfree = NULL;
 }
 
 /* -- inflate test routines -- */
@@ -289,7 +289,7 @@ static void inf(char *hex, char *what, unsigned step, int win, unsigned len, int
 
     mem_setup(&strm);
     strm.avail_in = 0;
-    strm.next_in = Z_NULL;
+    strm.next_in = NULL;
     ret = inflateInit2(&strm, win);
     if (ret != Z_OK) {
         mem_done(&strm, what);
@@ -351,12 +351,12 @@ static void cover_support(void)
 
     mem_setup(&strm);
     strm.avail_in = 0;
-    strm.next_in = Z_NULL;
+    strm.next_in = NULL;
     ret = inflateInit(&strm);                   assert(ret == Z_OK);
     mem_used(&strm, "inflate init");
     ret = inflatePrime(&strm, 5, 31);           assert(ret == Z_OK);
     ret = inflatePrime(&strm, -1, 0);           assert(ret == Z_OK);
-    ret = inflateSetDictionary(&strm, Z_NULL, 0);
+    ret = inflateSetDictionary(&strm, NULL, 0);
                                                 assert(ret == Z_STREAM_ERROR);
     ret = inflateEnd(&strm);                    assert(ret == Z_OK);
     mem_done(&strm, "prime");
@@ -369,13 +369,13 @@ static void cover_support(void)
 
     mem_setup(&strm);
     strm.avail_in = 0;
-    strm.next_in = Z_NULL;
+    strm.next_in = NULL;
     ret = inflateInit_(&strm, ZLIB_VERSION + 1, (int)sizeof(z_stream));
                                                 assert(ret == Z_VERSION_ERROR);
     mem_done(&strm, "wrong version");
 
     strm.avail_in = 0;
-    strm.next_in = Z_NULL;
+    strm.next_in = NULL;
     ret = inflateInit(&strm);                   assert(ret == Z_OK);
     ret = inflateEnd(&strm);                    assert(ret == Z_OK);
     fputs("inflate built-in memory routines\n", stderr);
@@ -388,9 +388,9 @@ static void cover_wrap(void)
     z_stream strm, copy;
     unsigned char dict[257];
 
-    ret = inflate(Z_NULL, 0);                   assert(ret == Z_STREAM_ERROR);
-    ret = inflateEnd(Z_NULL);                   assert(ret == Z_STREAM_ERROR);
-    ret = inflateCopy(Z_NULL, Z_NULL);          assert(ret == Z_STREAM_ERROR);
+    ret = inflate(NULL, 0);                     assert(ret == Z_STREAM_ERROR);
+    ret = inflateEnd(NULL);                     assert(ret == Z_STREAM_ERROR);
+    ret = inflateCopy(NULL, NULL);              assert(ret == Z_STREAM_ERROR);
     fputs("inflate bad parameters\n", stderr);
 
     inf("1f 8b 0 0", "bad gzip method", 0, 31, 0, Z_DATA_ERROR);
@@ -409,7 +409,7 @@ static void cover_wrap(void)
 
     mem_setup(&strm);
     strm.avail_in = 0;
-    strm.next_in = Z_NULL;
+    strm.next_in = NULL;
     ret = inflateInit2(&strm, -8);
     strm.avail_in = 2;
     strm.next_in = (void *)"\x63";
@@ -447,12 +447,12 @@ static unsigned pull(void *desc, const unsigned char **buf)
     static unsigned char dat[] = {0x63, 0, 2, 0};
     struct inflate_state *state;
 
-    if (desc == Z_NULL) {
+    if (desc == NULL) {
         next = 0;
         return 0;   /* no input (already provided at next_in) */
     }
     state = (void *)((z_stream *)desc)->state;
-    if (state != Z_NULL)
+    if (state != NULL)
         state->mode = SYNC;     /* force an otherwise impossible situation */
     return next < sizeof(dat) ? (*buf = dat + next++, 1) : 0;
 }
@@ -460,7 +460,7 @@ static unsigned pull(void *desc, const unsigned char **buf)
 static int push(void *desc, unsigned char *buf, unsigned len)
 {
     buf += len;
-    return desc != Z_NULL;      /* force error if desc not null */
+    return desc != NULL;        /* force error if desc not null */
 }
 
 /* cover inflateBack() up to common deflate data cases and after those */
@@ -470,27 +470,27 @@ static void cover_back(void)
     z_stream strm;
     unsigned char win[32768];
 
-    ret = inflateBackInit_(Z_NULL, 0, win, 0, 0);
+    ret = inflateBackInit_(NULL, 0, win, 0, 0);
                                                 assert(ret == Z_VERSION_ERROR);
-    ret = inflateBackInit(Z_NULL, 0, win);      assert(ret == Z_STREAM_ERROR);
-    ret = inflateBack(Z_NULL, Z_NULL, Z_NULL, Z_NULL, Z_NULL);
+    ret = inflateBackInit(NULL, 0, win);        assert(ret == Z_STREAM_ERROR);
+    ret = inflateBack(NULL, NULL, NULL, NULL, NULL);
                                                 assert(ret == Z_STREAM_ERROR);
-    ret = inflateBackEnd(Z_NULL);               assert(ret == Z_STREAM_ERROR);
+    ret = inflateBackEnd(NULL);                 assert(ret == Z_STREAM_ERROR);
     fputs("inflateBack bad parameters\n", stderr);
 
     mem_setup(&strm);
     ret = inflateBackInit(&strm, 15, win);      assert(ret == Z_OK);
     strm.avail_in = 2;
     strm.next_in = (void *)"\x03";
-    ret = inflateBack(&strm, pull, Z_NULL, push, Z_NULL);
+    ret = inflateBack(&strm, pull, NULL, push, NULL);
                                                 assert(ret == Z_STREAM_END);
         /* force output error */
     strm.avail_in = 3;
     strm.next_in = (void *)"\x63\x00";
-    ret = inflateBack(&strm, pull, Z_NULL, push, &strm);
+    ret = inflateBack(&strm, pull, NULL, push, &strm);
                                                 assert(ret == Z_BUF_ERROR);
         /* force mode error by mucking with state */
-    ret = inflateBack(&strm, pull, &strm, push, Z_NULL);
+    ret = inflateBack(&strm, pull, &strm, push, NULL);
                                                 assert(ret == Z_STREAM_ERROR);
     ret = inflateBackEnd(&strm);                assert(ret == Z_OK);
     mem_done(&strm, "inflateBack bad state");
@@ -527,7 +527,7 @@ static int try(char *hex, char *id, int err)
     strcat(prefix, "-late");
     mem_setup(&strm);
     strm.avail_in = 0;
-    strm.next_in = Z_NULL;
+    strm.next_in = NULL;
     ret = inflateInit2(&strm, err < 0 ? 47 : -15);
     assert(ret == Z_OK);
     strm.avail_in = len;
@@ -556,7 +556,7 @@ static int try(char *hex, char *id, int err)
         assert(ret == Z_OK);
         strm.avail_in = len;
         strm.next_in = in;
-        ret = inflateBack(&strm, pull, Z_NULL, push, Z_NULL);
+        ret = inflateBack(&strm, pull, NULL, push, NULL);
         assert(ret != Z_STREAM_ERROR);
         if (err) {
             assert(ret == Z_DATA_ERROR);
index 9c71fd1b8d5f02c66e028cd43e7f5c5c2396648e..5bfc1ce79502c5f07ed68f1fe498e0ba4ebdf696 100644 (file)
@@ -111,7 +111,7 @@ gzFile gz_open(const char *path, int fd, const char *mode)
     gz->write = strchr(mode, 'w') != NULL;
     gz->strm.zalloc = myalloc;
     gz->strm.zfree = myfree;
-    gz->strm.opaque = Z_NULL;
+    gz->strm.opaque = NULL;
     gz->buf = malloc(gz->write ? BUFLENW : BUFLEN);
 
     if (gz->buf == NULL) {
@@ -129,8 +129,8 @@ gzFile gz_open(const char *path, int fd, const char *mode)
     if (gz->write)
         ret = deflateInit2(&(gz->strm), level, 8, 15 + 16, 8, 0);
     else {
-        gz->strm.next_in = 0;
-        gz->strm.avail_in = Z_NULL;
+        gz->strm.next_in = NULL;
+        gz->strm.avail_in = 0;
         ret = inflateInit2(&(gz->strm), 15 + 16);
     }
     if (ret != Z_OK) {
@@ -213,7 +213,7 @@ int gzclose(gzFile gz)
         return Z_STREAM_ERROR;
     strm = &(gz->strm);
     if (gz->write) {
-        strm->next_in = Z_NULL;
+        strm->next_in = NULL;
         strm->avail_in = 0;
         do {
             strm->next_out = gz->buf;
index c2af140db1e1f29a8f1af7f5c1529637299f750a..50e0d869ba6b757702ff56dd303b7db474ce62e4 100644 (file)
--- a/uncompr.c
+++ b/uncompr.c
@@ -40,8 +40,8 @@ int ZEXPORT uncompress(unsigned char *dest, size_t *destLen, const unsigned char
 
     stream.next_in = (const unsigned char *)source;
     stream.avail_in = 0;
-    stream.zalloc = (alloc_func)0;
-    stream.zfree = (free_func)0;
+    stream.zalloc = NULL;
+    stream.zfree = NULL;
     stream.opaque = NULL;
 
     err = inflateInit(&stream);
index 7cacf1b79ed4c6a87cd72c62987310b486ccad0e..b6d10c86da5f91202f4bb207f936233815339b72 100644 (file)
@@ -118,9 +118,7 @@ typedef void       *voidp;
 #include <sys/types.h>      /* for off_t */
 #include <stdarg.h>         /* for va_list */
 
-#ifdef WIN32
-#  include <stddef.h>         /* for wchar_t */
-#endif
+#include <stddef.h>         /* for wchar_t and NULL */
 
 /* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
  * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
diff --git a/zlib.h b/zlib.h
index 774726242641968ab584aeba67f3d084e1a23306..d558f435231a5ac815c1f69f9bfbc552a58d2bb9 100644 (file)
--- a/zlib.h
+++ b/zlib.h
@@ -121,12 +121,12 @@ typedef struct gz_header_s {
     unsigned long   time;       /* modification time */
     int             xflags;     /* extra flags (not used when writing a gzip file) */
     int             os;         /* operating system */
-    unsigned char   *extra;     /* pointer to extra field or Z_NULL if none */
-    unsigned int    extra_len;  /* extra field length (valid if extra != Z_NULL) */
+    unsigned char   *extra;     /* pointer to extra field or NULL if none */
+    unsigned int    extra_len;  /* extra field length (valid if extra != NULL) */
     unsigned int    extra_max;  /* space at extra (only when reading header) */
-    unsigned char   *name;      /* pointer to zero-terminated file name or Z_NULL */
+    unsigned char   *name;      /* pointer to zero-terminated file name or NULL */
     unsigned int    name_max;   /* space at name (only when reading header) */
-    unsigned char   *comment;   /* pointer to zero-terminated comment or Z_NULL */
+    unsigned char   *comment;   /* pointer to zero-terminated comment or NULL */
     unsigned int    comm_max;   /* space at comment (only when reading header) */
     int             hcrc;       /* true if there was or will be a header crc */
     int             done;       /* true when done reading gzip header (not used when writing a gzip file) */
@@ -146,7 +146,7 @@ typedef gz_header *gz_headerp;
    memory management.  The compression library attaches no meaning to the
    opaque value.
 
-     zalloc must return Z_NULL if there is not enough memory for the object.
+     zalloc must return NULL if there is not enough memory for the object.
    If zlib is used in a multi-threaded application, zalloc and zfree must be
    thread safe.
 
@@ -202,7 +202,7 @@ typedef gz_header *gz_headerp;
 #define Z_DEFLATED   8
 /* The deflate compression method (the only one supported in this version) */
 
-#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
+#define Z_NULL  NULL  /* for compatibility with zlib, was for initializing zalloc, zfree, opaque */
 
 #define zlib_version zlibVersion()
 /* for compatibility with versions < 1.0.2 */
@@ -222,7 +222,7 @@ ZEXTERN int ZEXPORT deflateInit (z_stream *strm, int level);
 
      Initializes the internal stream state for compression.  The fields
    zalloc, zfree and opaque must be initialized before by the caller.  If
-   zalloc and zfree are set to Z_NULL, deflateInit updates them to use default
+   zalloc and zfree are set to NULL, deflateInit updates them to use default
    allocation functions.
 
      The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
@@ -340,7 +340,7 @@ ZEXTERN int ZEXPORT deflate(z_stream *strm, int flush);
   processed or more output produced), Z_STREAM_END if all input has been
   consumed and all output has been produced (only when flush is set to
   Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
-  if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible
+  if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible
   (for example avail_in or avail_out was zero).  Note that Z_BUF_ERROR is not
   fatal, and deflate() can be called again with more input and more output
   space to continue compressing.
@@ -366,11 +366,11 @@ ZEXTERN int ZEXPORT inflateInit (z_stream *strm);
 
      Initializes the internal stream state for decompression.  The fields
    next_in, avail_in, zalloc, zfree and opaque must be initialized before by
-   the caller.  If next_in is not Z_NULL and avail_in is large enough (the
+   the caller.  If next_in is not NULL and avail_in is large enough (the
    exact value depends on the compression method), inflateInit determines the
    compression method from the zlib header and allocates all data structures
    accordingly; otherwise the allocation will be deferred to the first call of
-   inflate.  If zalloc and zfree are set to Z_NULL, inflateInit updates them to
+   inflate.  If zalloc and zfree are set to NULL, inflateInit updates them to
    use default allocation functions.
 
      inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
@@ -492,7 +492,7 @@ ZEXTERN int ZEXPORT inflate(z_stream *strm, int flush);
   preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
   corrupted (input stream not conforming to the zlib format or incorrect check
   value), Z_STREAM_ERROR if the stream structure was inconsistent (for example
-  next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory,
+  next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory,
   Z_BUF_ERROR if no progress is possible or if there was not enough room in the
   output buffer when Z_FINISH is used.  Note that Z_BUF_ERROR is not fatal, and
   inflate() can be called again with more input and more output space to
@@ -627,7 +627,7 @@ ZEXTERN int ZEXPORT deflateSetDictionary(z_stream *strm,
    adler32 value is not computed and strm->adler is not set.
 
      deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
-   parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is
+   parameter is invalid (e.g.  dictionary being NULL) or the stream state is
    inconsistent (for example if deflate has already been called for this stream
    or if not at a block boundary for raw deflate).  deflateSetDictionary does
    not perform any compression: this will be done by deflate().
@@ -646,7 +646,7 @@ ZEXTERN int ZEXPORT deflateCopy(z_stream *dest, z_stream *source);
 
      deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
    enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
-   (such as zalloc being Z_NULL).  msg is left unchanged in both source and
+   (such as zalloc being NULL).  msg is left unchanged in both source and
    destination.
 */
 
@@ -658,7 +658,7 @@ ZEXTERN int ZEXPORT deflateReset(z_stream *strm);
    set unchanged.
 
      deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
-   stream state was inconsistent (such as zalloc or state being Z_NULL).
+   stream state was inconsistent (such as zalloc or state being NULL).
 */
 
 ZEXTERN int ZEXPORT deflateParams(z_stream *strm, int level, int strategy);
@@ -728,7 +728,7 @@ ZEXTERN int ZEXPORT deflatePending(z_stream *strm, uint32_t *pending, int *bits)
    provided would be due to the available output space having being consumed.
    The number of bits of output not provided are between 0 and 7, where they
    await more bits to join them in order to fill out a full byte.  If pending
-   or bits are Z_NULL, then those values are not set.
+   or bits are NULL, then those values are not set.
 
      deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source
    stream state was inconsistent.
@@ -757,8 +757,8 @@ ZEXTERN int ZEXPORT deflateSetHeader(z_stream *strm, gz_headerp head);
    deflate().  The text, time, os, extra field, name, and comment information
    in the provided gz_header structure are written to the gzip header (xflag is
    ignored -- the extra flags are set according to the compression level).  The
-   caller must assure that, if not Z_NULL, name and comment are terminated with
-   a zero byte, and that if extra is not Z_NULL, that extra_len bytes are
+   caller must assure that, if not NULL, name and comment are terminated with
+   a zero byte, and that if extra is not NULL, that extra_len bytes are
    available there.  If hcrc is true, a gzip header crc is included.  Note that
    the current versions of the command-line version of gzip (up through version
    1.3.x) do not support header crc's, and will report that it is a "multi-part
@@ -835,7 +835,7 @@ ZEXTERN int ZEXPORT inflateSetDictionary(z_stream *strm, const unsigned char *di
    that was used for compression is provided.
 
      inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
-   parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is
+   parameter is invalid (e.g.  dictionary being NULL) or the stream state is
    inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
    expected one (incorrect adler32 value).  inflateSetDictionary does not
    perform any decompression: this will be done by subsequent calls of
@@ -848,8 +848,8 @@ ZEXTERN int ZEXPORT inflateGetDictionary(z_stream *strm, unsigned char *dictiona
    set to the number of bytes in the dictionary, and that many bytes are copied
    to dictionary.  dictionary must have enough space, where 32768 bytes is
    always enough.  If inflateGetDictionary() is called with dictionary equal to
-   Z_NULL, then only the dictionary length is returned, and nothing is copied.
-   Similary, if dictLength is Z_NULL, then it is not set.
+   NULL, then only the dictionary length is returned, and nothing is copied.
+   Similary, if dictLength is NULL, then it is not set.
 
      inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the
    stream state is inconsistent.
@@ -885,7 +885,7 @@ ZEXTERN int ZEXPORT inflateCopy(z_stream *dest, z_stream *source);
 
      inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
    enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
-   (such as zalloc being Z_NULL).  msg is left unchanged in both source and
+   (such as zalloc being NULL).  msg is left unchanged in both source and
    destination.
 */
 
@@ -896,7 +896,7 @@ ZEXTERN int ZEXPORT inflateReset(z_stream *strm);
    stream will keep attributes that may have been set by inflateInit2.
 
      inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
-   stream state was inconsistent (such as zalloc or state being Z_NULL).
+   stream state was inconsistent (such as zalloc or state being NULL).
 */
 
 ZEXTERN int ZEXPORT inflateReset2(z_stream *strm, int windowBits);
@@ -906,7 +906,7 @@ ZEXTERN int ZEXPORT inflateReset2(z_stream *strm, int windowBits);
    the same as it is for inflateInit2.
 
      inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source
-   stream state was inconsistent (such as zalloc or state being Z_NULL), or if
+   stream state was inconsistent (such as zalloc or state being NULL), or if
    the windowBits parameter is invalid.
 */
 
@@ -971,16 +971,16 @@ ZEXTERN int ZEXPORT inflateGetHeader(z_stream *strm, gz_headerp head);
 
      The text, time, xflags, and os fields are filled in with the gzip header
    contents.  hcrc is set to true if there is a header CRC.  (The header CRC
-   was valid if done is set to one.) If extra is not Z_NULL, then extra_max
+   was valid if done is set to one.) If extra is not NULL, then extra_max
    contains the maximum number of bytes to write to extra.  Once done is true,
    extra_len contains the actual extra field length, and extra contains the
    extra field, or that field truncated if extra_max is less than extra_len.
-   If name is not Z_NULL, then up to name_max characters are written there,
+   If name is not NULL, then up to name_max characters are written there,
    terminated with a zero unless the length is greater than name_max.  If
-   comment is not Z_NULL, then up to comm_max characters are written there,
+   comment is not NULL, then up to comm_max characters are written there,
    terminated with a zero unless the length is greater than comm_max.  When any
-   of extra, name, or comment are not Z_NULL and the respective field is not
-   present in the header, then that field is set to Z_NULL to signal its
+   of extra, name, or comment are not NULL and the respective field is not
+   present in the header, then that field is set to NULL to signal its
    absence.  This allows the use of deflateSetHeader() with the returned
    structure to duplicate the header.  However if those fields are set to
    allocated memory, then the application will need to save those pointers
@@ -1001,7 +1001,7 @@ ZEXTERN int ZEXPORT inflateBackInit (z_stream *strm, int windowBits, unsigned ch
 
      Initialize the internal stream state for decompression using inflateBack()
    calls.  The fields zalloc, zfree and opaque in strm must be initialized
-   before the call.  If zalloc and zfree are Z_NULL, then the default library-
+   before the call.  If zalloc and zfree are NULL, then the default library-
    derived memory allocation routines are used.  windowBits is the base two
    logarithm of the window size, in the range 8..15.  window is a caller
    supplied buffer of that size.  Except for special applications where it is
@@ -1064,8 +1064,8 @@ ZEXTERN int ZEXPORT inflateBack(z_stream *strm, in_func in, void *in_desc, out_f
      For convenience, inflateBack() can be provided input on the first call by
    setting strm->next_in and strm->avail_in.  If that input is exhausted, then
    in() will be called.  Therefore strm->next_in must be initialized before
-   calling inflateBack().  If strm->next_in is Z_NULL, then in() will be called
-   immediately for input.  If strm->next_in is not Z_NULL, then strm->avail_in
+   calling inflateBack().  If strm->next_in is NULL, then in() will be called
+   immediately for input.  If strm->next_in is not NULL, then strm->avail_in
    must also be initialized, and then if strm->avail_in is not zero, input will
    initially be taken from strm->next_in[0 ..  strm->avail_in - 1].
 
@@ -1081,8 +1081,8 @@ ZEXTERN int ZEXPORT inflateBack(z_stream *strm, in_func in, void *in_desc, out_f
    in the deflate stream (in which case strm->msg is set to indicate the nature
    of the error), or Z_STREAM_ERROR if the stream was not properly initialized.
    In the case of Z_BUF_ERROR, an input or output error can be distinguished
-   using strm->next_in which will be Z_NULL only if in() returned an error.  If
-   strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning
+   using strm->next_in which will be NULL only if in() returned an error.  If
+   strm->next_in is not NULL, then the Z_BUF_ERROR was due to out() returning
    non-zero.  (in() will always be called before out(), so strm->next_in is
    assured to be defined if out() returns non-zero.) Note that inflateBack()
    cannot return Z_OK.
@@ -1556,7 +1556,7 @@ ZEXTERN void ZEXPORT gzclearerr(gzFile file);
 ZEXTERN uint32_t ZEXPORT adler32(uint32_t adler, const unsigned char *buf, uint32_t len);
 /*
      Update a running Adler-32 checksum with the bytes buf[0..len-1] and
-   return the updated checksum.  If buf is Z_NULL, this function returns the
+   return the updated checksum.  If buf is NULL, this function returns the
    required initial value for the checksum.
 
      An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
@@ -1564,7 +1564,7 @@ ZEXTERN uint32_t ZEXPORT adler32(uint32_t adler, const unsigned char *buf, uint3
 
    Usage example:
 
-     uint32_t adler = adler32(0L, Z_NULL, 0);
+     uint32_t adler = adler32(0L, NULL, 0);
 
      while (read_buffer(buffer, length) != EOF) {
        adler = adler32(adler, buffer, length);
@@ -1586,13 +1586,13 @@ ZEXTERN uint32_t ZEXPORT adler32_combine(uint32_t adler1, uint32_t adler2, z_off
 ZEXTERN uint32_t ZEXPORT crc32(uint32_t crc, const unsigned char *buf, z_off64_t len);
 /*
      Update a running CRC-32 with the bytes buf[0..len-1] and return the
-   updated CRC-32.  If buf is Z_NULL, this function returns the required
+   updated CRC-32.  If buf is NULL, this function returns the required
    initial value for the crc.  Pre- and post-conditioning (one's complement) is
    performed within this function so it shouldn't be done by the application.
 
    Usage example:
 
-     uint32_t crc = crc32(0L, Z_NULL, 0);
+     uint32_t crc = crc32(0L, NULL, 0);
 
      while (read_buffer(buffer, length) != EOF) {
        crc = crc32(crc, buffer, length);