From b78e7bed7cb96af941695704f3152c87a6148ee6 Mon Sep 17 00:00:00 2001
From: Marcus Comstedt <marcus@mc.pp.se>
Date: Sat, 30 Jan 2021 09:05:24 +0100
Subject: [PATCH] Build: Prevent malloc macro from expanding in
 ATTRIBUTE((malloc))

---
 src/dmalloc.h     | 2 +-
 src/pike_memory.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/dmalloc.h b/src/dmalloc.h
index 5a3ae9be6f..a73505fb6f 100644
--- a/src/dmalloc.h
+++ b/src/dmalloc.h
@@ -196,7 +196,7 @@ PMOD_EXPORT void* dlmemalign(size_t, size_t);
 PMOD_EXPORT void* dlvalloc(size_t);
 PMOD_EXPORT void* dlpvalloc(size_t);
 PMOD_EXPORT struct mallinfo dlmallinfo(void);
-#define malloc	  dlmalloc
+#define malloc(x) dlmalloc(x)
 #define free	  dlfree
 #define calloc    dlcalloc
 #define realloc	  dlrealloc
diff --git a/src/pike_memory.c b/src/pike_memory.c
index eb3e9b38f2..fc192ca44d 100644
--- a/src/pike_memory.c
+++ b/src/pike_memory.c
@@ -1100,7 +1100,7 @@ static MUTEX_T debug_malloc_mutex;
 #undef ENCAPSULATE_MALLOC
 #define calloc    dlcalloc
 #define free	  dlfree
-#define malloc	  dlmalloc
+#define malloc(x) dlmalloc(x)
 #define memalign  dlmemalign
 #define realloc	  dlrealloc
 #define valloc	  dlvalloc
@@ -1384,7 +1384,7 @@ void *fake_calloc(size_t x, size_t y)
 #define fake_calloc calloc
 #define fake_realloc realloc
 #else
-#define malloc fake_malloc
+#define malloc(x) fake_malloc(x)
 #define free fake_free
 #define realloc fake_realloc
 #define calloc fake_calloc
@@ -1394,7 +1394,7 @@ void *fake_calloc(size_t x, size_t y)
 /* Don't understand what this is supposed to do, but it won't work
  * with USE_DL_MALLOC. /mast */
 #ifdef WRAP
-#define malloc __real_malloc
+#define malloc(x) __real_malloc(x)
 #define free __real_free
 #define realloc __real_realloc
 #define calloc __real_calloc
-- 
GitLab