summaryrefslogtreecommitdiffstats
path: root/xmalloc.c
diff options
context:
space:
mode:
authorpgen <p.gen.progs@gmail.com>2021-01-28 21:41:01 +0100
committerpgen <p.gen.progs@gmail.com>2021-01-29 00:05:24 +0100
commitd467d0cf093c7c3a628a8a790f34ac216d764392 (patch)
tree500bf76999e6c478da045ea6aac1525a336435bf /xmalloc.c
parent2416f3fc5ba9a40cf5e7f5558d2d49b32638ad1e (diff)
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.
Diffstat (limited to 'xmalloc.c')
-rw-r--r--xmalloc.c33
1 files changed, 33 insertions, 0 deletions
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. */
/* ================== */