aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap
diff options
context:
space:
mode:
authorJoão Valverde <joao.valverde@tecnico.ulisboa.pt>2015-11-30 17:35:34 +0000
committerAnders Broman <a.broman58@gmail.com>2015-12-16 05:40:41 +0000
commitfb0246c6fd7cd34b820558f75eb48bba6326b768 (patch)
treee4e3acd0e25331e71d5521c6af6f1ed6a5dff089 /wiretap
parentc7ac304e7487489e9a32847ec3f5e253b7d81625 (diff)
Make zlib API constness-aware
ZLIB_CONST must be defined before including zlib.h to expose 'z_const'. Change-Id: Ic0dbd59ed3c760dd84ef4546f6ff4d5d3db91519 Reviewed-on: https://code.wireshark.org/review/12547 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Reviewed-by: Peter Wu <peter@lekensteyn.nl> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'wiretap')
-rw-r--r--wiretap/file_wrappers.c9
-rw-r--r--wiretap/wtap.c4
2 files changed, 3 insertions, 10 deletions
diff --git a/wiretap/file_wrappers.c b/wiretap/file_wrappers.c
index 5918a55f6f..07daad1d6d 100644
--- a/wiretap/file_wrappers.c
+++ b/wiretap/file_wrappers.c
@@ -48,6 +48,7 @@
#include <wsutil/file_util.h>
#ifdef HAVE_LIBZ
+#define ZLIB_CONST
#include <zlib.h>
#endif /* HAVE_LIBZ */
@@ -128,7 +129,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 */
- unsigned char *next_in; /* next input byte */
+ const guint8 *next_in; /* next input byte */
#ifdef HAVE_LIBZ
/* zlib inflate stream */
z_stream strm; /* stream structure in-place (not a pointer) */
@@ -1672,7 +1673,7 @@ gzwfile_write(GZWFILE_T state, const void *buf, guint len)
n = state->size - strm->avail_in;
if (n > len)
n = len;
- memcpy(strm->next_in + strm->avail_in, buf, n);
+ memcpy((Bytef *)strm->next_in + strm->avail_in, buf, n);
strm->avail_in += n;
state->pos += n;
buf = (const char *)buf + n;
@@ -1688,11 +1689,7 @@ 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;
diff --git a/wiretap/wtap.c b/wiretap/wtap.c
index 30b66cd46f..c4c35e8a74 100644
--- a/wiretap/wtap.c
+++ b/wiretap/wtap.c
@@ -27,10 +27,6 @@
#include <sys/types.h>
#endif
-#ifdef HAVE_LIBZ
-#include <zlib.h>
-#endif
-
#include "wtap-int.h"
#include "file_wrappers.h"