summaryrefslogtreecommitdiff
path: root/mm-internal.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2010-05-04 12:57:40 -0400
committerNick Mathewson <nickm@torproject.org>2010-05-04 12:57:40 -0400
commit99e50e90bd2a03638f9bef11dae12d9951b0c793 (patch)
tree3dba31cc73a4735c9d305b1f8a67f402c8567496 /mm-internal.h
parent20fda296c5faada095c7122244ecd6beff1c0931 (diff)
downloadlibevent-99e50e90bd2a03638f9bef11dae12d9951b0c793.tar.gz
Fix symbol conflict between mm_*() macros and libmm
Our mm_malloc, mm_calloc, etc functions were all exported, since C hasn't got a nice portable way to say "we want to use this function inside our library but not export it to others". But they apparently conflict with anything else that calls its symbols mm_*, as libmm does. This patch renames the mm_*() functions to event_mm_*_(, and defines maros in mm_internal so that all the code we have that uses mm_*() will still work. New code should also prefer the mm_*() macro names. Reported by Gernot Tenchio. Fixes sf bug 2996541
Diffstat (limited to 'mm-internal.h')
-rw-r--r--mm-internal.h19
1 files changed, 13 insertions, 6 deletions
diff --git a/mm-internal.h b/mm-internal.h
index 0d01a139..79855d6a 100644
--- a/mm-internal.h
+++ b/mm-internal.h
@@ -33,12 +33,19 @@ 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);
+/* Internal use only: Memory allocation functions. We give them nice short
+ * mm_names for our own use, but make sure that the symbols have longer names
+ * so they don't conflict with other libraries (like, say, libmm). */
+void *event_mm_malloc_(size_t sz);
+void *event_mm_calloc_(size_t count, size_t size);
+char *event_mm_strdup_(const char *s);
+void *event_mm_realloc_(void *p, size_t sz);
+void event_mm_free_(void *p);
+#define mm_malloc(sz) event_mm_malloc_(sz)
+#define mm_calloc(count, size) event_mm_calloc_((count), (size))
+#define mm_strdup(s) event_mm_strdup_(s)
+#define mm_realloc(p, sz) event_mm_realloc_((p), (sz))
+#define mm_free(p) event_mm_free_(p)
#else
#define mm_malloc(sz) malloc(sz)
#define mm_calloc(n, sz) calloc((n), (sz))