AC_ARG_ENABLE(thread-support,
AS_HELP_STRING(--enable-thread-support, enable support for threading),
[], [enable_thread_support=yes])
+AC_ARG_ENABLE(malloc-replacement,
+ AS_HELP_STRING(--disable-malloc-replacement, disable support for replacing the memory mgt functions),
+ [], [enable_malloc_replacement=yes])
AC_PROG_LIBTOOL
dnl Uncomment "AC_DISABLE_SHARED" to make shared librraries not get
[Define if libevent should not be compiled with thread support])
fi
+# check if we should hard-code the mm functions.
+if test x$enable_malloc_replacement = xno; then
+ AC_DEFINE(DISABLE_MM_REPLACEMENT, 1,
+ [Define if libevent should not allow replacing the mm functions])
+fi
+
# Add some more warnings which we use in development but not in the
# released versions. (Some relevant gcc versions can't handle these.)
if test x$enable_gcc_warnings = xyes; then
return (current_base->evsel->name);
}
+#ifndef _EVENT_DISABLE_MM_REPLACEMENT
static void *(*_mm_malloc_fn)(size_t sz) = NULL;
static void *(*_mm_realloc_fn)(void *p, size_t sz) = NULL;
static void (*_mm_free_fn)(void *p) = NULL;
_mm_realloc_fn = realloc_fn;
_mm_free_fn = free_fn;
}
-
+#endif
/* support for threading */
void (*_evthread_locking_fn)(int mode, void *lock) = NULL;
*/
int event_priority_set(struct event *, int);
+#ifndef _EVENT_DISABLE_MM_REPLACEMENT
/**
Override the functions that libevent uses for memory management.
void event_set_mem_functions(void *(*malloc_fn)(size_t sz),
void *(*realloc_fn)(void *ptr, size_t sz),
void (*free_fn)(void *ptr));
+#endif
void event_base_dump_events(struct event_base *, FILE *);
extern "C" {
#endif
+#ifndef _EVENT_DISABLE_MM_REPLACEMENT
/* Internal use only: Memory allocation functions. */
void *mm_malloc(size_t sz);
void *mm_calloc(size_t count, size_t size);
char *mm_strdup(const char *s);
void *mm_realloc(void *p, size_t sz);
void mm_free(void *p);
+#else
+#define mm_malloc(sz) malloc(sz)
+#define mm_calloc(n, sz) calloc((n), (sz))
+#define mm_strdup(s) strdup(s)
+#define mm_realloc(p, sz) realloc((p), (sz))
+#define mm_free(p) free(p)
+#endif
#ifdef __cplusplus
}