Commit f7bb70ab authored by Jörn Engel's avatar Jörn Engel Committed by Linus Torvalds

[PATCH] zlib cleanup: Z_NULL removal

s/Z_NULL/NULL/g.
parent 74030092
...@@ -91,7 +91,7 @@ typedef z_stream *z_streamp; ...@@ -91,7 +91,7 @@ typedef z_stream *z_streamp;
memory management. The compression library attaches no meaning to the memory management. The compression library attaches no meaning to the
opaque value. 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 If zlib is used in a multi-threaded application, zalloc and zfree must be
thread safe. thread safe.
...@@ -153,8 +153,6 @@ typedef z_stream *z_streamp; ...@@ -153,8 +153,6 @@ typedef z_stream *z_streamp;
#define Z_DEFLATED 8 #define Z_DEFLATED 8
/* The deflate compression method (the only one supported in this version) */ /* The deflate compression method (the only one supported in this version) */
#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */
/* basic functions */ /* basic functions */
extern const char * zlib_zlibVersion (void); extern const char * zlib_zlibVersion (void);
...@@ -176,7 +174,7 @@ extern int deflateInit (z_streamp strm, int level); ...@@ -176,7 +174,7 @@ extern int deflateInit (z_streamp strm, int level);
Initializes the internal stream state for compression. The fields Initializes the internal stream state for compression. The fields
zalloc, zfree and opaque must be initialized before by the caller. zalloc, zfree and opaque must be initialized before by the caller.
If zalloc and zfree are set to Z_NULL, deflateInit updates them to If zalloc and zfree are set to NULL, deflateInit updates them to
use default allocation functions. use default allocation functions.
The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
...@@ -298,11 +296,11 @@ extern int zlib_inflateInit (z_streamp strm); ...@@ -298,11 +296,11 @@ extern int zlib_inflateInit (z_streamp strm);
Initializes the internal stream state for decompression. The fields Initializes the internal stream state for decompression. The fields
next_in, avail_in, and workspace must be initialized before by next_in, avail_in, and workspace must be initialized before by
the caller. If next_in is not Z_NULL and avail_in is large enough (the exact 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 value depends on the compression method), inflateInit determines the
compression method from the zlib header and allocates all data structures compression method from the zlib header and allocates all data structures
accordingly; otherwise the allocation will be deferred to the first call of 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. use default allocation functions.
inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
......
...@@ -81,7 +81,7 @@ typedef uLong (*check_func) (uLong check, const Byte *buf, ...@@ -81,7 +81,7 @@ typedef uLong (*check_func) (uLong check, const Byte *buf,
An Adler-32 checksum is almost as reliable as a CRC32 but can be computed An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
much faster. Usage example: much faster. Usage example:
uLong adler = adler32(0L, Z_NULL, 0); uLong adler = adler32(0L, NULL, 0);
while (read_buffer(buffer, length) != EOF) { while (read_buffer(buffer, length) != EOF) {
adler = adler32(adler, buffer, length); adler = adler32(adler, buffer, length);
...@@ -96,7 +96,7 @@ static inline uLong zlib_adler32(uLong adler, ...@@ -96,7 +96,7 @@ static inline uLong zlib_adler32(uLong adler,
unsigned long s2 = (adler >> 16) & 0xffff; unsigned long s2 = (adler >> 16) & 0xffff;
int k; int k;
if (buf == Z_NULL) return 1L; if (buf == NULL) return 1L;
while (len > 0) { while (len > 0) {
k = len < NMAX ? len : NMAX; k = len < NMAX ? len : NMAX;
......
...@@ -199,13 +199,13 @@ int zlib_deflateInit2_( ...@@ -199,13 +199,13 @@ int zlib_deflateInit2_(
* output size for (length,distance) codes is <= 24 bits. * output size for (length,distance) codes is <= 24 bits.
*/ */
if (version == Z_NULL || version[0] != my_version[0] || if (version == NULL || version[0] != my_version[0] ||
stream_size != sizeof(z_stream)) { stream_size != sizeof(z_stream)) {
return Z_VERSION_ERROR; return Z_VERSION_ERROR;
} }
if (strm == Z_NULL) return Z_STREAM_ERROR; if (strm == NULL) return Z_STREAM_ERROR;
strm->msg = Z_NULL; strm->msg = NULL;
if (level == Z_DEFAULT_COMPRESSION) level = 6; if (level == Z_DEFAULT_COMPRESSION) level = 6;
...@@ -266,7 +266,7 @@ int zlib_deflateSetDictionary( ...@@ -266,7 +266,7 @@ int zlib_deflateSetDictionary(
uInt n; uInt n;
IPos hash_head = 0; IPos hash_head = 0;
if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL) if (strm == NULL || strm->state == NULL || dictionary == NULL)
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
s = (deflate_state *) strm->state; s = (deflate_state *) strm->state;
...@@ -305,11 +305,11 @@ int zlib_deflateReset( ...@@ -305,11 +305,11 @@ int zlib_deflateReset(
{ {
deflate_state *s; deflate_state *s;
if (strm == Z_NULL || strm->state == Z_NULL) if (strm == NULL || strm->state == NULL)
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
strm->total_in = strm->total_out = 0; strm->total_in = strm->total_out = 0;
strm->msg = Z_NULL; strm->msg = NULL;
strm->data_type = Z_UNKNOWN; strm->data_type = Z_UNKNOWN;
s = (deflate_state *)strm->state; s = (deflate_state *)strm->state;
...@@ -340,7 +340,7 @@ int zlib_deflateParams( ...@@ -340,7 +340,7 @@ int zlib_deflateParams(
compress_func func; compress_func func;
int err = Z_OK; int err = Z_OK;
if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; if (strm == NULL || strm->state == NULL) return Z_STREAM_ERROR;
s = (deflate_state *) strm->state; s = (deflate_state *) strm->state;
if (level == Z_DEFAULT_COMPRESSION) { if (level == Z_DEFAULT_COMPRESSION) {
...@@ -396,7 +396,7 @@ static void flush_pending( ...@@ -396,7 +396,7 @@ static void flush_pending(
if (len > strm->avail_out) len = strm->avail_out; if (len > strm->avail_out) len = strm->avail_out;
if (len == 0) return; if (len == 0) return;
if (strm->next_out != Z_NULL) { if (strm->next_out != NULL) {
memcpy(strm->next_out, s->pending_out, len); memcpy(strm->next_out, s->pending_out, len);
strm->next_out += len; strm->next_out += len;
} }
...@@ -418,13 +418,13 @@ int zlib_deflate( ...@@ -418,13 +418,13 @@ int zlib_deflate(
int old_flush; /* value of flush param for previous deflate call */ int old_flush; /* value of flush param for previous deflate call */
deflate_state *s; deflate_state *s;
if (strm == Z_NULL || strm->state == Z_NULL || if (strm == NULL || strm->state == NULL ||
flush > Z_FINISH || flush < 0) { flush > Z_FINISH || flush < 0) {
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
} }
s = (deflate_state *) strm->state; s = (deflate_state *) strm->state;
if ((strm->next_in == Z_NULL && strm->avail_in != 0) || if ((strm->next_in == NULL && strm->avail_in != 0) ||
(s->status == FINISH_STATE && flush != Z_FINISH)) { (s->status == FINISH_STATE && flush != Z_FINISH)) {
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
} }
...@@ -555,7 +555,7 @@ int zlib_deflateEnd( ...@@ -555,7 +555,7 @@ int zlib_deflateEnd(
int status; int status;
deflate_state *s; deflate_state *s;
if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; if (strm == NULL || strm->state == NULL) return Z_STREAM_ERROR;
s = (deflate_state *) strm->state; s = (deflate_state *) strm->state;
status = s->status; status = s->status;
...@@ -564,7 +564,7 @@ int zlib_deflateEnd( ...@@ -564,7 +564,7 @@ int zlib_deflateEnd(
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
} }
strm->state = Z_NULL; strm->state = NULL;
return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK; return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK;
} }
...@@ -586,7 +586,7 @@ int zlib_deflateCopy ( ...@@ -586,7 +586,7 @@ int zlib_deflateCopy (
deflate_workspace *mem; deflate_workspace *mem;
if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) { if (source == NULL || dest == NULL || source->state == NULL) {
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
} }
...@@ -968,7 +968,7 @@ static void fill_window(s) ...@@ -968,7 +968,7 @@ static void fill_window(s)
#define FLUSH_BLOCK_ONLY(s, eof) { \ #define FLUSH_BLOCK_ONLY(s, eof) { \
zlib_tr_flush_block(s, (s->block_start >= 0L ? \ zlib_tr_flush_block(s, (s->block_start >= 0L ? \
(char *)&s->window[(unsigned)s->block_start] : \ (char *)&s->window[(unsigned)s->block_start] : \
(char *)Z_NULL), \ (char *)NULL), \
(ulg)((long)s->strstart - s->block_start), \ (ulg)((long)s->strstart - s->block_start), \
(eof)); \ (eof)); \
s->block_start = s->strstart; \ s->block_start = s->strstart; \
......
...@@ -71,7 +71,7 @@ void zlib_inflate_blocks_reset( ...@@ -71,7 +71,7 @@ void zlib_inflate_blocks_reset(
uLong *c uLong *c
) )
{ {
if (c != Z_NULL) if (c != NULL)
*c = s->check; *c = s->check;
if (s->mode == CODES) if (s->mode == CODES)
zlib_inflate_codes_free(s->sub.decode.codes, z); zlib_inflate_codes_free(s->sub.decode.codes, z);
...@@ -79,8 +79,8 @@ void zlib_inflate_blocks_reset( ...@@ -79,8 +79,8 @@ void zlib_inflate_blocks_reset(
s->bitk = 0; s->bitk = 0;
s->bitb = 0; s->bitb = 0;
s->read = s->write = s->window; s->read = s->write = s->window;
if (s->checkfn != Z_NULL) if (s->checkfn != NULL)
z->adler = s->check = (*s->checkfn)(0L, (const Byte *)Z_NULL, 0); z->adler = s->check = (*s->checkfn)(0L, (const Byte *)NULL, 0);
} }
inflate_blocks_statef *zlib_inflate_blocks_new( inflate_blocks_statef *zlib_inflate_blocks_new(
...@@ -97,7 +97,7 @@ inflate_blocks_statef *zlib_inflate_blocks_new( ...@@ -97,7 +97,7 @@ inflate_blocks_statef *zlib_inflate_blocks_new(
s->end = s->window + w; s->end = s->window + w;
s->checkfn = c; s->checkfn = c;
s->mode = TYPE; s->mode = TYPE;
zlib_inflate_blocks_reset(s, z, Z_NULL); zlib_inflate_blocks_reset(s, z, NULL);
return s; return s;
} }
...@@ -141,7 +141,7 @@ int zlib_inflate_blocks( ...@@ -141,7 +141,7 @@ int zlib_inflate_blocks(
zlib_inflate_trees_fixed(&bl, &bd, &tl, &td, z); zlib_inflate_trees_fixed(&bl, &bd, &tl, &td, z);
s->sub.decode.codes = zlib_inflate_codes_new(bl, bd, tl, td, z); s->sub.decode.codes = zlib_inflate_codes_new(bl, bd, tl, td, z);
if (s->sub.decode.codes == Z_NULL) if (s->sub.decode.codes == NULL)
{ {
r = Z_MEM_ERROR; r = Z_MEM_ERROR;
LEAVE LEAVE
...@@ -270,7 +270,7 @@ int zlib_inflate_blocks( ...@@ -270,7 +270,7 @@ int zlib_inflate_blocks(
s->sub.trees.index = i; s->sub.trees.index = i;
} }
} }
s->sub.trees.tb = Z_NULL; s->sub.trees.tb = NULL;
{ {
uInt bl, bd; uInt bl, bd;
inflate_huft *tl, *td; inflate_huft *tl, *td;
...@@ -289,7 +289,7 @@ int zlib_inflate_blocks( ...@@ -289,7 +289,7 @@ int zlib_inflate_blocks(
r = t; r = t;
LEAVE LEAVE
} }
if ((c = zlib_inflate_codes_new(bl, bd, tl, td, z)) == Z_NULL) if ((c = zlib_inflate_codes_new(bl, bd, tl, td, z)) == NULL)
{ {
r = Z_MEM_ERROR; r = Z_MEM_ERROR;
LEAVE LEAVE
...@@ -333,7 +333,7 @@ int zlib_inflate_blocks_free( ...@@ -333,7 +333,7 @@ int zlib_inflate_blocks_free(
z_streamp z z_streamp z
) )
{ {
zlib_inflate_blocks_reset(s, z, Z_NULL); zlib_inflate_blocks_reset(s, z, NULL);
return Z_OK; return Z_OK;
} }
...@@ -351,7 +351,7 @@ void zlib_inflate_set_dictionary( ...@@ -351,7 +351,7 @@ void zlib_inflate_set_dictionary(
/* Returns true if inflate is currently at the end of a block generated /* Returns true if inflate is currently at the end of a block generated
* by Z_SYNC_FLUSH or Z_FULL_FLUSH. * by Z_SYNC_FLUSH or Z_FULL_FLUSH.
* IN assertion: s != Z_NULL * IN assertion: s != NULL
*/ */
int zlib_inflate_blocks_sync_point( int zlib_inflate_blocks_sync_point(
inflate_blocks_statef *s inflate_blocks_statef *s
......
...@@ -18,12 +18,12 @@ int zlib_inflateReset( ...@@ -18,12 +18,12 @@ int zlib_inflateReset(
z_streamp z z_streamp z
) )
{ {
if (z == Z_NULL || z->state == Z_NULL || z->workspace == Z_NULL) if (z == NULL || z->state == NULL || z->workspace == NULL)
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
z->total_in = z->total_out = 0; z->total_in = z->total_out = 0;
z->msg = Z_NULL; z->msg = NULL;
z->state->mode = z->state->nowrap ? BLOCKS : METHOD; z->state->mode = z->state->nowrap ? BLOCKS : METHOD;
zlib_inflate_blocks_reset(z->state->blocks, z, Z_NULL); zlib_inflate_blocks_reset(z->state->blocks, z, NULL);
return Z_OK; return Z_OK;
} }
...@@ -32,11 +32,11 @@ int zlib_inflateEnd( ...@@ -32,11 +32,11 @@ int zlib_inflateEnd(
z_streamp z z_streamp z
) )
{ {
if (z == Z_NULL || z->state == Z_NULL || z->workspace == Z_NULL) if (z == NULL || z->state == NULL || z->workspace == NULL)
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
if (z->state->blocks != Z_NULL) if (z->state->blocks != NULL)
zlib_inflate_blocks_free(z->state->blocks, z); zlib_inflate_blocks_free(z->state->blocks, z);
z->state = Z_NULL; z->state = NULL;
return Z_OK; return Z_OK;
} }
...@@ -48,16 +48,16 @@ int zlib_inflateInit2_( ...@@ -48,16 +48,16 @@ int zlib_inflateInit2_(
int stream_size int stream_size
) )
{ {
if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || if (version == NULL || version[0] != ZLIB_VERSION[0] ||
stream_size != sizeof(z_stream) || z->workspace == Z_NULL) stream_size != sizeof(z_stream) || z->workspace == NULL)
return Z_VERSION_ERROR; return Z_VERSION_ERROR;
/* initialize state */ /* initialize state */
if (z == Z_NULL) if (z == NULL)
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
z->msg = Z_NULL; z->msg = NULL;
z->state = &WS(z)->internal_state; z->state = &WS(z)->internal_state;
z->state->blocks = Z_NULL; z->state->blocks = NULL;
/* handle undocumented nowrap option (no zlib header or check) */ /* handle undocumented nowrap option (no zlib header or check) */
z->state->nowrap = 0; z->state->nowrap = 0;
...@@ -77,8 +77,8 @@ int zlib_inflateInit2_( ...@@ -77,8 +77,8 @@ int zlib_inflateInit2_(
/* create inflate_blocks state */ /* create inflate_blocks state */
if ((z->state->blocks = if ((z->state->blocks =
zlib_inflate_blocks_new(z, z->state->nowrap ? Z_NULL : zlib_adler32, (uInt)1 << w)) zlib_inflate_blocks_new(z, z->state->nowrap ? NULL : zlib_adler32, (uInt)1 << w))
== Z_NULL) == NULL)
{ {
zlib_inflateEnd(z); zlib_inflateEnd(z);
return Z_MEM_ERROR; return Z_MEM_ERROR;
...@@ -125,7 +125,7 @@ int zlib_inflate( ...@@ -125,7 +125,7 @@ int zlib_inflate(
int r, trv; int r, trv;
uInt b; uInt b;
if (z == Z_NULL || z->state == Z_NULL || z->next_in == Z_NULL) if (z == NULL || z->state == NULL || z->next_in == NULL)
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
trv = f == Z_FINISH ? Z_BUF_ERROR : Z_OK; trv = f == Z_FINISH ? Z_BUF_ERROR : Z_OK;
r = Z_BUF_ERROR; r = Z_BUF_ERROR;
...@@ -260,7 +260,7 @@ int zlib_inflateSync( ...@@ -260,7 +260,7 @@ int zlib_inflateSync(
uLong r, w; /* temporaries to save total_in and total_out */ uLong r, w; /* temporaries to save total_in and total_out */
/* set up */ /* set up */
if (z == Z_NULL || z->state == Z_NULL) if (z == NULL || z->state == NULL)
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
if (z->state->mode != I_BAD) if (z->state->mode != I_BAD)
{ {
...@@ -313,7 +313,7 @@ int zlib_inflateSyncPoint( ...@@ -313,7 +313,7 @@ int zlib_inflateSyncPoint(
z_streamp z z_streamp z
) )
{ {
if (z == Z_NULL || z->state == Z_NULL || z->state->blocks == Z_NULL) if (z == NULL || z->state == NULL || z->state->blocks == NULL)
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
return zlib_inflate_blocks_sync_point(z->state->blocks); return zlib_inflate_blocks_sync_point(z->state->blocks);
} }
...@@ -352,7 +352,7 @@ static int zlib_inflate_addhistory(inflate_blocks_statef *s, ...@@ -352,7 +352,7 @@ static int zlib_inflate_addhistory(inflate_blocks_statef *s,
/* is there room until end of buffer? */ /* is there room until end of buffer? */
if (t > m) t = m; if (t > m) t = m;
/* update check information */ /* update check information */
if (s->checkfn != Z_NULL) if (s->checkfn != NULL)
s->check = (*s->checkfn)(s->check, q, t); s->check = (*s->checkfn)(s->check, q, t);
memcpy(q, p, t); memcpy(q, p, t);
q += t; q += t;
......
...@@ -139,7 +139,7 @@ static int huft_build( ...@@ -139,7 +139,7 @@ static int huft_build(
} while (--i); } while (--i);
if (c[0] == n) /* null input--all zero length codes */ if (c[0] == n) /* null input--all zero length codes */
{ {
*t = (inflate_huft *)Z_NULL; *t = (inflate_huft *)NULL;
*m = 0; *m = 0;
return Z_OK; return Z_OK;
} }
...@@ -193,8 +193,8 @@ static int huft_build( ...@@ -193,8 +193,8 @@ static int huft_build(
p = v; /* grab values in bit order */ p = v; /* grab values in bit order */
h = -1; /* no tables yet--level -1 */ h = -1; /* no tables yet--level -1 */
w = -l; /* bits decoded == (l * h) */ w = -l; /* bits decoded == (l * h) */
u[0] = (inflate_huft *)Z_NULL; /* just to keep compilers happy */ u[0] = (inflate_huft *)NULL; /* just to keep compilers happy */
q = (inflate_huft *)Z_NULL; /* ditto */ q = (inflate_huft *)NULL; /* ditto */
z = 0; /* ditto */ z = 0; /* ditto */
/* go through the bit lengths (k already is bits in shortest code) */ /* go through the bit lengths (k already is bits in shortest code) */
...@@ -302,7 +302,7 @@ int zlib_inflate_trees_bits( ...@@ -302,7 +302,7 @@ int zlib_inflate_trees_bits(
uInt *v; /* work area for huft_build */ uInt *v; /* work area for huft_build */
v = WS(z)->tree_work_area_1; v = WS(z)->tree_work_area_1;
r = huft_build(c, 19, 19, (uInt*)Z_NULL, (uInt*)Z_NULL, r = huft_build(c, 19, 19, (uInt*)NULL, (uInt*)NULL,
tb, bb, hp, &hn, v); tb, bb, hp, &hn, v);
if (r == Z_DATA_ERROR) if (r == Z_DATA_ERROR)
z->msg = (char*)"oversubscribed dynamic bit lengths tree"; z->msg = (char*)"oversubscribed dynamic bit lengths tree";
......
...@@ -44,7 +44,7 @@ int zlib_inflate_flush( ...@@ -44,7 +44,7 @@ int zlib_inflate_flush(
z->total_out += n; z->total_out += n;
/* update check information */ /* update check information */
if (s->checkfn != Z_NULL) if (s->checkfn != NULL)
z->adler = s->check = (*s->checkfn)(s->check, q, n); z->adler = s->check = (*s->checkfn)(s->check, q, n);
/* copy as far as end of window */ /* copy as far as end of window */
...@@ -70,7 +70,7 @@ int zlib_inflate_flush( ...@@ -70,7 +70,7 @@ int zlib_inflate_flush(
z->total_out += n; z->total_out += n;
/* update check information */ /* update check information */
if (s->checkfn != Z_NULL) if (s->checkfn != NULL)
z->adler = s->check = (*s->checkfn)(s->check, q, n); z->adler = s->check = (*s->checkfn)(s->check, q, n);
/* copy */ /* copy */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment