[Zlib-devel] [PATCH] use "zalloc_func" and "zfree_func" instead of "alloc_func" and "free_func"
lepton
lepton at sina.com
Fri Feb 6 03:09:57 EST 2004
Package: zlib
Version: 1.2.1
Hi!
when I compile a program use zlib and openssl,I found if I
include zlib.h first,I will get compile errors like this:
In file included from /usr/include/openssl/comp.h:5,
from /usr/include/openssl/ssl.h:63,
from include/emily.h:36,
from src/lib/emily.c:2:
/usr/include/openssl/crypto.h:324: parse error before `free_func'
I found the reason is that zlib has typedef "free_func" and "alloc_func".
I think such name is not a good choice for a libarary, I think we'd
better change it to something like "zfree_func" and "zalloc_func".
The following is my patch for it:
diff -ur zlib-1.2.1/compress.c zlib-1.2.1-new/compress.c
--- zlib-1.2.1/compress.c Mon Jul 7 13:37:56 2003
+++ zlib-1.2.1-new/compress.c Fri Feb 6 15:43:09 2004
@@ -39,8 +39,8 @@
stream.avail_out = (uInt)*destLen;
if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
- stream.zalloc = (alloc_func)0;
- stream.zfree = (free_func)0;
+ stream.zalloc = (zalloc_func)0;
+ stream.zfree = (zfree_func)0;
stream.opaque = (voidpf)0;
err = deflateInit(&stream, level);
diff -ur zlib-1.2.1/contrib/infback9/infback9.c zlib-1.2.1-new/contrib/infback9/infback9.c
--- zlib-1.2.1/contrib/infback9/infback9.c Sun Sep 14 23:49:53 2003
+++ zlib-1.2.1-new/contrib/infback9/infback9.c Fri Feb 6 15:49:47 2004
@@ -30,11 +30,11 @@
if (strm == Z_NULL || window == Z_NULL)
return Z_STREAM_ERROR;
strm->msg = Z_NULL; /* in case we return an error */
- if (strm->zalloc == (alloc_func)0) {
+ if (strm->zalloc == (zalloc_func)0) {
strm->zalloc = zcalloc;
strm->opaque = (voidpf)0;
}
- if (strm->zfree == (free_func)0) strm->zfree = zcfree;
+ if (strm->zfree == (zfree_func)0) strm->zfree = zcfree;
state = (struct inflate_state FAR *)ZALLOC(strm, 1,
sizeof(struct inflate_state));
if (state == Z_NULL) return Z_MEM_ERROR;
@@ -596,7 +596,7 @@
int ZEXPORT inflateBack9End(strm)
z_stream FAR *strm;
{
- if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
+ if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (zfree_func)0)
return Z_STREAM_ERROR;
ZFREE(strm, strm->state);
strm->state = Z_NULL;
diff -ur zlib-1.2.1/contrib/minizip/unzip.c zlib-1.2.1-new/contrib/minizip/unzip.c
--- zlib-1.2.1/contrib/minizip/unzip.c Wed Sep 10 16:00:16 2003
+++ zlib-1.2.1-new/contrib/minizip/unzip.c Fri Feb 6 15:44:19 2004
@@ -1126,8 +1126,8 @@
if ((s->cur_file_info.compression_method==Z_DEFLATED) &&
(!raw))
{
- pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
- pfile_in_zip_read_info->stream.zfree = (free_func)0;
+ pfile_in_zip_read_info->stream.zalloc = (zalloc_func)0;
+ pfile_in_zip_read_info->stream.zfree = (zfree_func)0;
pfile_in_zip_read_info->stream.opaque = (voidpf)0;
pfile_in_zip_read_info->stream.next_in = (voidpf)0;
pfile_in_zip_read_info->stream.avail_in = 0;
diff -ur zlib-1.2.1/contrib/minizip/zip.c zlib-1.2.1-new/contrib/minizip/zip.c
--- zlib-1.2.1/contrib/minizip/zip.c Wed Sep 10 16:00:18 2003
+++ zlib-1.2.1-new/contrib/minizip/zip.c Fri Feb 6 15:44:08 2004
@@ -817,8 +817,8 @@
if ((err==ZIP_OK) && (zi->ci.method == Z_DEFLATED) && (!zi->ci.raw))
{
- zi->ci.stream.zalloc = (alloc_func)0;
- zi->ci.stream.zfree = (free_func)0;
+ zi->ci.stream.zalloc = (zalloc_func)0;
+ zi->ci.stream.zfree = (zfree_func)0;
zi->ci.stream.opaque = (voidpf)0;
if (windowBits>0)
diff -ur zlib-1.2.1/deflate.c zlib-1.2.1-new/deflate.c
--- zlib-1.2.1/deflate.c Sun Nov 9 10:33:12 2003
+++ zlib-1.2.1-new/deflate.c Fri Feb 6 15:50:08 2004
@@ -240,11 +240,11 @@
if (strm == Z_NULL) return Z_STREAM_ERROR;
strm->msg = Z_NULL;
- if (strm->zalloc == (alloc_func)0) {
+ if (strm->zalloc == (zalloc_func)0) {
strm->zalloc = zcalloc;
strm->opaque = (voidpf)0;
}
- if (strm->zfree == (free_func)0) strm->zfree = zcfree;
+ if (strm->zfree == (zfree_func)0) strm->zfree = zcfree;
#ifdef FASTEST
if (level != 0) level = 1;
@@ -361,7 +361,7 @@
deflate_state *s;
if (strm == Z_NULL || strm->state == Z_NULL ||
- strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) {
+ strm->zalloc == (zalloc_func)0 || strm->zfree == (zfree_func)0) {
return Z_STREAM_ERROR;
}
diff -ur zlib-1.2.1/example.c zlib-1.2.1-new/example.c
--- zlib-1.2.1/example.c Sun Sep 14 08:23:20 2003
+++ zlib-1.2.1-new/example.c Fri Feb 6 15:46:01 2004
@@ -176,8 +176,8 @@
int err;
uLong len = (uLong)strlen(hello)+1;
- c_stream.zalloc = (alloc_func)0;
- c_stream.zfree = (free_func)0;
+ c_stream.zalloc = (zalloc_func)0;
+ c_stream.zfree = (zfree_func)0;
c_stream.opaque = (voidpf)0;
err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION);
@@ -215,8 +215,8 @@
strcpy((char*)uncompr, "garbage");
- d_stream.zalloc = (alloc_func)0;
- d_stream.zfree = (free_func)0;
+ d_stream.zalloc = (zalloc_func)0;
+ d_stream.zfree = (zfree_func)0;
d_stream.opaque = (voidpf)0;
d_stream.next_in = compr;
@@ -254,8 +254,8 @@
z_stream c_stream; /* compression stream */
int err;
- c_stream.zalloc = (alloc_func)0;
- c_stream.zfree = (free_func)0;
+ c_stream.zalloc = (zalloc_func)0;
+ c_stream.zfree = (zfree_func)0;
c_stream.opaque = (voidpf)0;
err = deflateInit(&c_stream, Z_BEST_SPEED);
@@ -311,8 +311,8 @@
strcpy((char*)uncompr, "garbage");
- d_stream.zalloc = (alloc_func)0;
- d_stream.zfree = (free_func)0;
+ d_stream.zalloc = (zalloc_func)0;
+ d_stream.zfree = (zfree_func)0;
d_stream.opaque = (voidpf)0;
d_stream.next_in = compr;
@@ -351,8 +351,8 @@
int err;
uInt len = (uInt)strlen(hello)+1;
- c_stream.zalloc = (alloc_func)0;
- c_stream.zfree = (free_func)0;
+ c_stream.zalloc = (zalloc_func)0;
+ c_stream.zfree = (zfree_func)0;
c_stream.opaque = (voidpf)0;
err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION);
@@ -390,8 +390,8 @@
strcpy((char*)uncompr, "garbage");
- d_stream.zalloc = (alloc_func)0;
- d_stream.zfree = (free_func)0;
+ d_stream.zalloc = (zalloc_func)0;
+ d_stream.zfree = (zfree_func)0;
d_stream.opaque = (voidpf)0;
d_stream.next_in = compr;
@@ -432,8 +432,8 @@
z_stream c_stream; /* compression stream */
int err;
- c_stream.zalloc = (alloc_func)0;
- c_stream.zfree = (free_func)0;
+ c_stream.zalloc = (zalloc_func)0;
+ c_stream.zfree = (zfree_func)0;
c_stream.opaque = (voidpf)0;
err = deflateInit(&c_stream, Z_BEST_COMPRESSION);
@@ -471,8 +471,8 @@
strcpy((char*)uncompr, "garbage");
- d_stream.zalloc = (alloc_func)0;
- d_stream.zfree = (free_func)0;
+ d_stream.zalloc = (zalloc_func)0;
+ d_stream.zfree = (zfree_func)0;
d_stream.opaque = (voidpf)0;
d_stream.next_in = compr;
diff -ur zlib-1.2.1/gzio.c zlib-1.2.1-new/gzio.c
--- zlib-1.2.1/gzio.c Mon Oct 27 11:05:12 2003
+++ zlib-1.2.1-new/gzio.c Fri Feb 6 15:46:05 2004
@@ -108,8 +108,8 @@
s = (gz_stream *)ALLOC(sizeof(gz_stream));
if (!s) return Z_NULL;
- s->stream.zalloc = (alloc_func)0;
- s->stream.zfree = (free_func)0;
+ s->stream.zalloc = (zalloc_func)0;
+ s->stream.zfree = (zfree_func)0;
s->stream.opaque = (voidpf)0;
s->stream.next_in = s->inbuf = Z_NULL;
s->stream.next_out = s->outbuf = Z_NULL;
diff -ur zlib-1.2.1/infback.c zlib-1.2.1-new/infback.c
--- zlib-1.2.1/infback.c Tue Aug 12 07:48:06 2003
+++ zlib-1.2.1-new/infback.c Fri Feb 6 15:50:34 2004
@@ -41,11 +41,11 @@
windowBits < 8 || windowBits > 15)
return Z_STREAM_ERROR;
strm->msg = Z_NULL; /* in case we return an error */
- if (strm->zalloc == (alloc_func)0) {
+ if (strm->zalloc == (zalloc_func)0) {
strm->zalloc = zcalloc;
strm->opaque = (voidpf)0;
}
- if (strm->zfree == (free_func)0) strm->zfree = zcfree;
+ if (strm->zfree == (zfree_func)0) strm->zfree = zcfree;
state = (struct inflate_state FAR *)ZALLOC(strm, 1,
sizeof(struct inflate_state));
if (state == Z_NULL) return Z_MEM_ERROR;
@@ -610,7 +610,7 @@
int ZEXPORT inflateBackEnd(strm)
z_stream FAR *strm;
{
- if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
+ if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (zfree_func)0)
return Z_STREAM_ERROR;
ZFREE(strm, strm->state);
strm->state = Z_NULL;
diff -ur zlib-1.2.1/inflate.c zlib-1.2.1-new/inflate.c
--- zlib-1.2.1/inflate.c Sun Oct 26 14:15:36 2003
+++ zlib-1.2.1-new/inflate.c Fri Feb 6 15:50:24 2004
@@ -134,11 +134,11 @@
return Z_VERSION_ERROR;
if (strm == Z_NULL) return Z_STREAM_ERROR;
strm->msg = Z_NULL; /* in case we return an error */
- if (strm->zalloc == (alloc_func)0) {
+ if (strm->zalloc == (zalloc_func)0) {
strm->zalloc = zcalloc;
strm->opaque = (voidpf)0;
}
- if (strm->zfree == (free_func)0) strm->zfree = zcfree;
+ if (strm->zfree == (zfree_func)0) strm->zfree = zcfree;
state = (struct inflate_state FAR *)
ZALLOC(strm, 1, sizeof(struct inflate_state));
if (state == Z_NULL) return Z_MEM_ERROR;
@@ -1085,7 +1085,7 @@
z_streamp strm;
{
struct inflate_state FAR *state;
- if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
+ if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (zfree_func)0)
return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)strm->state;
if (state->window != Z_NULL) ZFREE(strm, state->window);
@@ -1238,7 +1238,7 @@
/* check input */
if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL ||
- source->zalloc == (alloc_func)0 || source->zfree == (free_func)0)
+ source->zalloc == (zalloc_func)0 || source->zfree == (zfree_func)0)
return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)source->state;
diff -ur zlib-1.2.1/old/zlib.html zlib-1.2.1-new/old/zlib.html
--- zlib-1.2.1/old/zlib.html Mon Mar 11 21:55:37 2002
+++ zlib-1.2.1-new/old/zlib.html Fri Feb 6 15:48:24 2004
@@ -856,8 +856,8 @@
char *<a name="msg">msg</a>; /* last error message, NULL if no error */
struct internal_state FAR *<a name="state">state</a>; /* not visible by applications */
- alloc_func <a name="zalloc">zalloc</a>; /* used to allocate the internal <a href="#state">state</a> */
- free_func <a name="zfree">zfree</a>; /* used to free the internal <a href="#state">state</a> */
+ zalloc_func <a name="zalloc">zalloc</a>; /* used to allocate the internal <a href="#state">state</a> */
+ zfree_func <a name="zfree">zfree</a>; /* used to free the internal <a href="#state">state</a> */
voidpf <a name="opaque">opaque</a>; /* private data object passed to <a href="#zalloc">zalloc</a> and <a href="#zfree">zfree</a> */
int <a name="data_type">data_type</a>; /* best guess about the data type: ascii or binary */
diff -ur zlib-1.2.1/uncompr.c zlib-1.2.1-new/uncompr.c
--- zlib-1.2.1/uncompr.c Mon Jul 7 13:36:56 2003
+++ zlib-1.2.1-new/uncompr.c Fri Feb 6 15:46:50 2004
@@ -41,8 +41,8 @@
stream.avail_out = (uInt)*destLen;
if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
- stream.zalloc = (alloc_func)0;
- stream.zfree = (free_func)0;
+ stream.zalloc = (zalloc_func)0;
+ stream.zfree = (zfree_func)0;
err = inflateInit(&stream);
if (err != Z_OK) return err;
diff -ur zlib-1.2.1/zlib.h zlib-1.2.1-new/zlib.h
--- zlib-1.2.1/zlib.h Tue Nov 18 05:19:11 2003
+++ zlib-1.2.1-new/zlib.h Fri Feb 6 15:42:49 2004
@@ -76,8 +76,8 @@
crash even in case of corrupted input.
*/
-typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
-typedef void (*free_func) OF((voidpf opaque, voidpf address));
+typedef voidpf (*zalloc_func) OF((voidpf opaque, uInt items, uInt size));
+typedef void (*zfree_func) OF((voidpf opaque, voidpf address));
struct internal_state;
@@ -93,8 +93,8 @@
char *msg; /* last error message, NULL if no error */
struct internal_state FAR *state; /* not visible by applications */
- alloc_func zalloc; /* used to allocate the internal state */
- free_func zfree; /* used to free the internal state */
+ zalloc_func zalloc; /* used to allocate the internal state */
+ zfree_func zfree; /* used to free the internal state */
voidpf opaque; /* private data object passed to zalloc and zfree */
int data_type; /* best guess about the data type: ascii or binary */
More information about the Zlib-devel
mailing list