CC="${PTHREAD_CC}"
TS_CHECK_JEMALLOC
-if test "$has_jemalloc" = "0"; then
+if test "$has_jemalloc" = "1"; then
+ AC_DEFINE([ENABLE_JEMALLOC], [1], [compile and link with jemalloc])
+else
TS_CHECK_TCMALLOC
+ if test "$has_tcmalloc" = "1"; then
+ AC_DEFINE([ENABLE_TCMALLOC], [1], [compile and link with tcmalloc])
+ else
+ AC_C_MALLOPT
+ AC_C_MALLINFO
+ fi
fi
-if test "$has_jemalloc$has_tcmalloc" = "00"; then
- AC_C_MALLOPT
- AC_C_MALLINFO
-fi
+
AC_TYPE_UINT8_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
#include <config.h>
#endif
-#ifdef has_jemalloc
+/* select the memory allocator, based on autoconf findings */
+#if defined(ENABLE_JEMALLOC)
+
+#if defined(HAVE_JEMALLOC_JEMALLOC_H)
#include <jemalloc/jemalloc.h>
-#undef HAVE_C_MALLOPT
-#undef HAVE_C_MALLINFO
-#elif has_tcmalloc
-#include <google/tcmalloc.h>
-#undef HAVE_C_MALLOPT
-#undef HAVE_C_MALLINFO
#else
#include <malloc.h>
#endif
+#elif defined(ENABLE_TCMALLOC)
+
+#include <google/tcmalloc.h>
+
+#else /* !defined(ENABLE_JEMALLOC) && !defined(ENABLE_TCMALLOC) */
+
+#include <malloc.h>
+
+#endif
+
#include <pthread.h>
#include <errno.h>
break;
case 'v':
// TODO: Outsource version to makefile which can compute version from git.
- printf("netdata " VERSION "\n");
+ printf("netdata %s\n", VERSION);
return 0;
case 'W':
{