]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: remove dependency to zlib.h
authorWilliam Lallemand <wlallemand@exceliance.fr>
Wed, 31 Oct 2012 10:19:18 +0000 (11:19 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 5 Nov 2012 09:23:16 +0000 (10:23 +0100)
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.

include/types/compression.h
include/types/session.h
src/compression.c

index dfff2f97e992365c0bcf16f9266649e88f359360..6f418fa0574159728b0b81cb3688f45f41c4918e 100644 (file)
 #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 {
 };
 
 struct comp_ctx {
+#ifdef USE_ZLIB
        z_stream strm; /* zlib stream */
+#endif /* USE_ZLIB */
 };
 
 struct comp_algo {
index 5546be8c83d84a96257382b137227a60356a5a50..ae11f81790c5ec94a0d0ec568cc4e9a8656359d6 100644 (file)
@@ -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>
index 2c0e4f99eeea16d5d84f75ff4886fd4430761100..1f12df9aec78e9dffebb08de71358ff6d9dae6d3 100644 (file)
@@ -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 http_compression_buffer_end(struct session *s, struct buffer **in, struct bu
        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 @@ int http_compression_buffer_end(struct session *s, struct buffer **in, struct bu
        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;