Revert "Make zlib API constness-aware"

This reverts commit fb0246c6fd.  That commit assumes that if you define Z_CONST, z_const will be defined; that is *not* the case with older versions of zlib, which don't define z_const under any circumstances.

Change-Id: I6f9b7ea18922799b1aaf94dc2c63120128f2550a
Reviewed-on: https://code.wireshark.org/review/12671
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2015-12-16 08:59:01 +00:00
parent bfe73e3ad7
commit 6d60c4d468
4 changed files with 11 additions and 6 deletions

View File

@ -42,7 +42,6 @@
#include "packet-ssl.h"
#ifdef HAVE_LIBZ
#define ZLIB_CONST
#include <zlib.h>
#endif
@ -962,7 +961,7 @@ static guint8* spdy_decompress_header_block(tvbuff_t *tvb,
const guint8 *hptr = tvb_get_ptr(tvb, offset, length);
guint8 *uncomp_block = (guint8 *)wmem_alloc(wmem_packet_scope(), DECOMPRESS_BUFSIZE);
decomp->next_in = hptr;
decomp->next_in = (Bytef *)hptr;
decomp->avail_in = length;
decomp->next_out = uncomp_block;
decomp->avail_out = DECOMPRESS_BUFSIZE;

View File

@ -28,7 +28,6 @@
#include <string.h>
#ifdef HAVE_LIBZ
#define ZLIB_CONST
#include <zlib.h>
#endif

View File

@ -48,7 +48,6 @@
#include <wsutil/file_util.h>
#ifdef HAVE_LIBZ
#define ZLIB_CONST
#include <zlib.h>
#endif /* HAVE_LIBZ */
@ -129,7 +128,7 @@ struct wtap_reader {
const char *err_info; /* additional error information string for some errors */
guint avail_in; /* number of bytes available at next_in */
const guint8 *next_in; /* next input byte */
unsigned char *next_in; /* next input byte */
#ifdef HAVE_LIBZ
/* zlib inflate stream */
z_stream strm; /* stream structure in-place (not a pointer) */
@ -1673,7 +1672,7 @@ gzwfile_write(GZWFILE_T state, const void *buf, guint len)
n = state->size - strm->avail_in;
if (n > len)
n = len;
memcpy((Bytef *)strm->next_in + strm->avail_in, buf, n);
memcpy(strm->next_in + strm->avail_in, buf, n);
strm->avail_in += n;
state->pos += n;
buf = (const char *)buf + n;
@ -1689,7 +1688,11 @@ gzwfile_write(GZWFILE_T state, const void *buf, guint len)
/* directly compress user buffer to file */
strm->avail_in = len;
#if ZLIB_CONST
strm->next_in = (z_const Bytef *)buf;
#else
strm->next_in = (Bytef *)buf;
#endif
state->pos += len;
if (gz_comp(state, Z_NO_FLUSH) == -1)
return 0;

View File

@ -27,6 +27,10 @@
#include <sys/types.h>
#endif
#ifdef HAVE_LIBZ
#include <zlib.h>
#endif
#include "wtap-int.h"
#include "file_wrappers.h"