BUILD: remove dependency to zlib.h
The build was dependent of the zlib.h header, regardless of the USE_ZLIB
option. The fix consists of several #ifdef in the source code.
It removes the overhead of the zstream structure in the session when you
don't use the option.
diff --git a/include/types/compression.h b/include/types/compression.h
index dfff2f9..6f418fa 100644
--- a/include/types/compression.h
+++ b/include/types/compression.h
@@ -23,8 +23,12 @@
#ifndef _TYPES_COMP_H
#define _TYPES_COMP_H
+#ifdef USE_ZLIB
+
#include <zlib.h>
+#endif /* USE_ZLIB */
+
struct comp {
struct comp_algo *algos;
struct comp_type *types;
@@ -32,7 +36,9 @@
};
struct comp_ctx {
+#ifdef USE_ZLIB
z_stream strm; /* zlib stream */
+#endif /* USE_ZLIB */
};
struct comp_algo {
diff --git a/include/types/session.h b/include/types/session.h
index 5546be8..ae11f81 100644
--- a/include/types/session.h
+++ b/include/types/session.h
@@ -33,6 +33,7 @@
#include <types/channel.h>
#include <types/compression.h>
+
#include <types/proto_http.h>
#include <types/proxy.h>
#include <types/queue.h>
diff --git a/src/compression.c b/src/compression.c
index 2c0e4f9..1f12df9 100644
--- a/src/compression.c
+++ b/src/compression.c
@@ -13,6 +13,7 @@
#include <stdio.h>
+#ifdef USE_ZLIB
/* Note: the crappy zlib and openssl libs both define the "free_func" type.
* That's a very clever idea to use such a generic name in general purpose
* libraries, really... The zlib one is easier to redefine than openssl's,
@@ -21,6 +22,7 @@
#define free_func zlib_free_func
#include <zlib.h>
#undef free_func
+#endif /* USE_ZLIB */
#include <common/compat.h>
@@ -200,6 +202,8 @@
int left;
struct http_msg *msg = &s->txn.rsp;
struct buffer *ib = *in, *ob = *out;
+
+#ifdef USE_ZLIB
int ret;
/* flush data here */
@@ -212,6 +216,8 @@
if (ret < 0)
return -1; /* flush failed */
+#endif /* USE_ZLIB */
+
if (ob->i > 8) {
/* more than a chunk size => some data were emitted */
char *tail = ob->p + ob->i;