Skip to content

Commit

Permalink
Remove FAR variants of voidpf
Browse files Browse the repository at this point in the history
And a few Bytef leftovers from test/example.c
  • Loading branch information
Dead2 committed Oct 18, 2014
1 parent de4fe1b commit 8999d0a
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 32 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 = (voidpf)0;
stream.opaque = (voidp)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 @@ -285,7 +285,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
return Z_STREAM_ERROR;
#else
strm->zalloc = zcalloc;
strm->opaque = (voidpf)0;
strm->opaque = (voidp)0;
#endif
}
if (strm->zfree == (free_func)0)
Expand Down Expand Up @@ -1081,12 +1081,12 @@ int ZEXPORT deflateCopy (dest, source)

ss = source->state;

zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));
zmemcpy((voidp)dest, (voidp)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;
zmemcpy((voidpf)ds, (voidpf)ss, sizeof(deflate_state));
zmemcpy((voidp)ds, (voidp)ss, sizeof(deflate_state));
ds->strm = dest;

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

zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos));
zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos));
zmemcpy((voidp)ds->prev, (voidp)ss->prev, ds->w_size * sizeof(Pos));
zmemcpy((voidp)ds->head, (voidp)ss->head, ds->hash_size * sizeof(Pos));
zmemcpy(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 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 = (voidpf)0;
strm->opaque = (voidp)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 = (voidpf)0;
strm->opaque = (voidp)0;
#endif
}
if (strm->zfree == (free_func)0)
Expand Down Expand Up @@ -1463,8 +1463,8 @@ z_streamp source;
}

/* copy state */
zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));
zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state));
zmemcpy((voidp)dest, (voidp)source, sizeof(z_stream));
zmemcpy((voidp)copy, (voidp)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
22 changes: 11 additions & 11 deletions test/example.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void test_compress(compr, comprLen, uncompr, uncomprLen)
int err;
uLong len = (uLong)strlen(hello)+1;

err = compress(compr, &comprLen, (const Bytef*)hello, len);
err = compress(compr, &comprLen, (const Byte*)hello, len);
CHECK_ERR(err, "compress");

strcpy((char*)uncompr, "garbage");
Expand Down Expand Up @@ -201,7 +201,7 @@ void test_deflate(compr, comprLen)

c_stream.zalloc = zalloc;
c_stream.zfree = zfree;
c_stream.opaque = (voidpf)0;
c_stream.opaque = (voidp)0;

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

d_stream.zalloc = zalloc;
d_stream.zfree = zfree;
d_stream.opaque = (voidpf)0;
d_stream.opaque = (voidp)0;

d_stream.next_in = compr;
d_stream.avail_in = 0;
Expand Down Expand Up @@ -279,7 +279,7 @@ void test_large_deflate(compr, comprLen, uncompr, uncomprLen)

c_stream.zalloc = zalloc;
c_stream.zfree = zfree;
c_stream.opaque = (voidpf)0;
c_stream.opaque = (voidp)0;

err = deflateInit(&c_stream, Z_BEST_SPEED);
CHECK_ERR(err, "deflateInit");
Expand Down Expand Up @@ -336,7 +336,7 @@ void test_large_inflate(compr, comprLen, uncompr, uncomprLen)

d_stream.zalloc = zalloc;
d_stream.zfree = zfree;
d_stream.opaque = (voidpf)0;
d_stream.opaque = (voidp)0;

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

c_stream.zalloc = zalloc;
c_stream.zfree = zfree;
c_stream.opaque = (voidpf)0;
c_stream.opaque = (voidp)0;

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

d_stream.zalloc = zalloc;
d_stream.zfree = zfree;
d_stream.opaque = (voidpf)0;
d_stream.opaque = (voidp)0;

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

c_stream.zalloc = zalloc;
c_stream.zfree = zfree;
c_stream.opaque = (voidpf)0;
c_stream.opaque = (voidp)0;

err = deflateInit(&c_stream, Z_BEST_COMPRESSION);
CHECK_ERR(err, "deflateInit");

err = deflateSetDictionary(&c_stream,
(const Bytef*)dictionary, (int)sizeof(dictionary));
(const Byte*)dictionary, (int)sizeof(dictionary));
CHECK_ERR(err, "deflateSetDictionary");

dictId = c_stream.adler;
Expand Down Expand Up @@ -496,7 +496,7 @@ void test_dict_inflate(compr, comprLen, uncompr, uncomprLen)

d_stream.zalloc = zalloc;
d_stream.zfree = zfree;
d_stream.opaque = (voidpf)0;
d_stream.opaque = (voidp)0;

d_stream.next_in = compr;
d_stream.avail_in = (uInt)comprLen;
Expand All @@ -515,7 +515,7 @@ void test_dict_inflate(compr, comprLen, uncompr, uncomprLen)
fprintf(stderr, "unexpected dictionary");
exit(1);
}
err = inflateSetDictionary(&d_stream, (const Bytef*)dictionary,
err = inflateSetDictionary(&d_stream, (const Byte*)dictionary,
(int)sizeof(dictionary));
}
CHECK_ERR(err, "inflate with dict");
Expand Down
8 changes: 4 additions & 4 deletions zlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ extern "C" {
even in case of corrupted input.
*/

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

struct internal_state;

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

alloc_func zalloc; /* used to allocate the internal state */
free_func zfree; /* used to free the internal state */
voidpf opaque; /* private data object passed to zalloc and zfree */
voidp 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 @@ -1101,7 +1101,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 voidpf (pointer)
5.4: size of voidp (pointer)
7.6: size of z_off_t
Compiler, assembler, and debug options:
Expand Down
14 changes: 7 additions & 7 deletions zutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ uLong ZEXPORT zlibCompileFlags()
case 8: flags += 2 << 2; break;
default: flags += 3 << 2;
}
switch ((int)(sizeof(voidpf))) {
switch ((int)(sizeof(voidp))) {
case 2: break;
case 4: flags += 1 << 4; break;
case 8: flags += 2 << 4; break;
Expand Down Expand Up @@ -120,19 +120,19 @@ const char * ZEXPORT zError(err)

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

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

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

0 comments on commit 8999d0a

Please sign in to comment.