From: Willy Tarreau Date: Tue, 3 Nov 2020 14:50:40 +0000 (+0100) Subject: MINOR: compat: automatically include malloc.h on glibc X-Git-Tag: v2.4-dev1~102 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d3c7003d91a2c3b48f0f1fee3eb361f4121057b;p=thirdparty%2Fhaproxy.git MINOR: compat: automatically include malloc.h on glibc This is in order to access malloc_trim() which is convenient after clearing huge maps to reclaim memory. When this is detected, we also define HA_HAVE_MALLOC_TRIM. --- diff --git a/include/haproxy/compat.h b/include/haproxy/compat.h index 97cde46c3e..581141c1f1 100644 --- a/include/haproxy/compat.h +++ b/include/haproxy/compat.h @@ -240,6 +240,15 @@ typedef struct { } empty_t; #endif #endif +/* malloc_trim() can be very convenient to reclaim unused memory especially + * from huge pattern files. It's available (and really usable) in glibc 2.8 and + * above. + */ +#if (defined(__GNU_LIBRARY__) && (__GLIBC__ > 2 || __GLIBC__ == 2 && __GLIBC_MINOR__ >= 8)) +#include +#define HA_HAVE_MALLOC_TRIM +#endif + /* Max number of file descriptors we send in one sendmsg(). Linux seems to be * able to send 253 fds per sendmsg(), not sure about the other OSes. */