From d467d0cf093c7c3a628a8a790f34ac216d764392 Mon Sep 17 00:00:00 2001
From: pgen
Date: Thu, 28 Jan 2021 21:41:01 +0100
Subject: Make sure that smenu can be built and run on AIX.
- Add some encodings.
- Manage some terminfo database specificities.
- Avoid type collisions.
- Work around an incompatibility in memory management functions.
---
xmalloc.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
(limited to 'xmalloc.c')
diff --git a/xmalloc.c b/xmalloc.c
index 0eeab68..1ab13ff 100644
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -19,6 +19,39 @@
#include "config.h"
#include "xmalloc.h"
+/* The following rpl_* function are necessary for AIX which doesn't */
+/* provide 'GNU compatible' allocation functions. */
+/* Every call to malloc()/realloc() is then replaced by a call to */
+/* rpl_malloc()/rpl_realloc() as defined in the GNU generated config.h. */
+/* """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" */
+
+#ifdef malloc
+
+#undef malloc
+extern void * malloc(size_t);
+
+void *
+rpl_malloc(size_t size)
+{
+ if (!size)
+ size++;
+ return malloc(size);
+}
+
+#undef realloc
+extern void *
+realloc(void *, size_t);
+
+void *
+rpl_realloc(void * ptr, size_t size)
+{
+ if (!size)
+ size++;
+ return (ptr ? realloc(ptr, size) : malloc(size));
+}
+
+#endif
+
/* ================== */
/* Customized malloc. */
/* ================== */
--
cgit v1.2.3