Skip to content

Commit

Permalink
Cleanup: Replace 'voidp' with 'void *'
Browse files Browse the repository at this point in the history
  • Loading branch information
Dead2 committed Apr 26, 2015
1 parent f4e0118 commit e5ee314
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)

stream.zalloc = (alloc_func)0;
stream.zfree = (free_func)0;
stream.opaque = (voidp)0;
stream.opaque = (void *)0;

err = deflateInit(&stream, level);
if (err != Z_OK) return err;
Expand Down
10 changes: 5 additions & 5 deletions deflate.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
return Z_STREAM_ERROR;
#else
strm->zalloc = zcalloc;
strm->opaque = (voidp)0;
strm->opaque = (void *)0;
#endif
}
if (strm->zfree == (free_func)0)
Expand Down Expand Up @@ -1074,12 +1074,12 @@ int ZEXPORT deflateCopy (dest, source)

ss = source->state;

memcpy((voidp)dest, (voidp)source, sizeof(z_stream));
memcpy((void *)dest, (void *)source, sizeof(z_stream));

ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));
if (ds == Z_NULL) return Z_MEM_ERROR;
dest->state = (struct internal_state *) ds;
memcpy((voidp)ds, (voidp)ss, sizeof(deflate_state));
memcpy((void *)ds, (void *)ss, sizeof(deflate_state));
ds->strm = dest;

ds->window = (Byte *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
Expand All @@ -1095,8 +1095,8 @@ int ZEXPORT deflateCopy (dest, source)
}

memcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
memcpy((voidp)ds->prev, (voidp)ss->prev, ds->w_size * sizeof(Pos));
memcpy((voidp)ds->head, (voidp)ss->head, ds->hash_size * sizeof(Pos));
memcpy((void *)ds->prev, (void *)ss->prev, ds->w_size * sizeof(Pos));
memcpy((void *)ds->head, (void *)ss->head, ds->hash_size * sizeof(Pos));
memcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);

ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
Expand Down
2 changes: 1 addition & 1 deletion gzread.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ local int gz_skip(gz_statep state, z_off64_t len)
/* -- see zlib.h -- */
int ZEXPORT gzread(file, buf, len)
gzFile file;
voidp buf;
void *buf;
unsigned len;
{
unsigned got, n;
Expand Down
2 changes: 1 addition & 1 deletion infback.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ int stream_size;
return Z_STREAM_ERROR;
#else
strm->zalloc = zcalloc;
strm->opaque = (voidp)0;
strm->opaque = (void *)0;
#endif
}
if (strm->zfree == (free_func)0)
Expand Down
6 changes: 3 additions & 3 deletions inflate.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ int stream_size;
return Z_STREAM_ERROR;
#else
strm->zalloc = zcalloc;
strm->opaque = (voidp)0;
strm->opaque = (void *)0;
#endif
}
if (strm->zfree == (free_func)0)
Expand Down Expand Up @@ -1456,8 +1456,8 @@ z_streamp source;
}

/* copy state */
memcpy((voidp)dest, (voidp)source, sizeof(z_stream));
memcpy((voidp)copy, (voidp)state, sizeof(struct inflate_state));
memcpy((void *)dest, (void *)source, sizeof(z_stream));
memcpy((void *)copy, (void *)state, sizeof(struct inflate_state));
if (state->lencode >= state->codes &&
state->lencode <= state->codes + ENOUGH - 1) {
copy->lencode = copy->codes + (state->lencode - state->codes);
Expand Down
16 changes: 8 additions & 8 deletions test/example.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void test_deflate(Byte *compr, uLong comprLen)

c_stream.zalloc = zalloc;
c_stream.zfree = zfree;
c_stream.opaque = (voidp)0;
c_stream.opaque = (void *)0;

err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION);
CHECK_ERR(err, "deflateInit");
Expand Down Expand Up @@ -224,7 +224,7 @@ void test_inflate(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)

d_stream.zalloc = zalloc;
d_stream.zfree = zfree;
d_stream.opaque = (voidp)0;
d_stream.opaque = (void *)0;

d_stream.next_in = compr;
d_stream.avail_in = 0;
Expand Down Expand Up @@ -261,7 +261,7 @@ void test_large_deflate(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomp

c_stream.zalloc = zalloc;
c_stream.zfree = zfree;
c_stream.opaque = (voidp)0;
c_stream.opaque = (void *)0;

err = deflateInit(&c_stream, Z_BEST_SPEED);
CHECK_ERR(err, "deflateInit");
Expand Down Expand Up @@ -316,7 +316,7 @@ void test_large_inflate(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomp

d_stream.zalloc = zalloc;
d_stream.zfree = zfree;
d_stream.opaque = (voidp)0;
d_stream.opaque = (void *)0;

d_stream.next_in = compr;
d_stream.avail_in = (uInt)comprLen;
Expand Down Expand Up @@ -354,7 +354,7 @@ void test_flush(Byte *compr, uLong *comprLen)

c_stream.zalloc = zalloc;
c_stream.zfree = zfree;
c_stream.opaque = (voidp)0;
c_stream.opaque = (void *)0;

err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION);
CHECK_ERR(err, "deflateInit");
Expand Down Expand Up @@ -391,7 +391,7 @@ void test_sync(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)

d_stream.zalloc = zalloc;
d_stream.zfree = zfree;
d_stream.opaque = (voidp)0;
d_stream.opaque = (void *)0;

d_stream.next_in = compr;
d_stream.avail_in = 2; /* just read the zlib header */
Expand Down Expand Up @@ -431,7 +431,7 @@ void test_dict_deflate(Byte *compr, uLong comprLen)

c_stream.zalloc = zalloc;
c_stream.zfree = zfree;
c_stream.opaque = (voidp)0;
c_stream.opaque = (void *)0;

err = deflateInit(&c_stream, Z_BEST_COMPRESSION);
CHECK_ERR(err, "deflateInit");
Expand Down Expand Up @@ -468,7 +468,7 @@ void test_dict_inflate(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncompr

d_stream.zalloc = zalloc;
d_stream.zfree = zfree;
d_stream.opaque = (voidp)0;
d_stream.opaque = (void *)0;

d_stream.next_in = compr;
d_stream.avail_in = (uInt)comprLen;
Expand Down
10 changes: 5 additions & 5 deletions zlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ extern "C" {
even in case of corrupted input.
*/

typedef voidp (*alloc_func) (voidp opaque, uInt items, uInt size);
typedef void (*free_func) (voidp opaque, voidp address);
typedef void *(*alloc_func) (void *opaque, uInt items, uInt size);
typedef void (*free_func) (void *opaque, void *address);

struct internal_state;

Expand All @@ -103,7 +103,7 @@ typedef struct z_stream_s {

alloc_func zalloc; /* used to allocate the internal state */
free_func zfree; /* used to free the internal state */
voidp opaque; /* private data object passed to zalloc and zfree */
void *opaque; /* private data object passed to zalloc and zfree */

int data_type; /* best guess about the data type: binary or text */
uLong adler; /* adler32 value of the uncompressed data */
Expand Down Expand Up @@ -1108,7 +1108,7 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags (void);
Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other:
1.0: size of uInt
3.2: size of uLong
5.4: size of voidp (pointer)
5.4: size of void * (pointer)
7.6: size of z_off_t
Compiler, assembler, and debug options:
Expand Down Expand Up @@ -1308,7 +1308,7 @@ ZEXTERN int ZEXPORT gzsetparams (gzFile file, int level, int strategy);
opened for writing.
*/

ZEXTERN int ZEXPORT gzread (gzFile file, voidp buf, unsigned len);
ZEXTERN int ZEXPORT gzread (gzFile file, void *buf, unsigned len);
/*
Reads the given number of uncompressed bytes from the compressed file. If
the input file is not in gzip format, gzread copies the given number of
Expand Down
10 changes: 5 additions & 5 deletions zutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ uLong ZEXPORT zlibCompileFlags()
case 8: flags += 2 << 2; break;
default: flags += 3 << 2;
}
switch ((int)(sizeof(voidp))) {
switch ((int)(sizeof(void *))) {
case 2: break;
case 4: flags += 1 << 4; break;
case 8: flags += 2 << 4; break;
Expand Down Expand Up @@ -111,14 +111,14 @@ const char * ZEXPORT zError(err)

#ifndef MY_ZCALLOC /* Any system without a special alloc function */

voidp ZLIB_INTERNAL zcalloc (voidp opaque, unsigned items, unsigned size)
void ZLIB_INTERNAL *zcalloc (void *opaque, unsigned items, unsigned size)
{
if (opaque) items += size - size; /* make compiler happy */
return sizeof(uInt) > 2 ? (voidp)malloc(items * size) :
(voidp)calloc(items, size);
return sizeof(uInt) > 2 ? (void *)malloc(items * size) :
(void *)calloc(items, size);
}

void ZLIB_INTERNAL zcfree (voidp opaque, voidp ptr)
void ZLIB_INTERNAL zcfree (void *opaque, void *ptr)
{
free(ptr);
if (opaque) return; /* make compiler happy */
Expand Down

0 comments on commit e5ee314

Please sign in to comment.