diff options
author | pgen <p.gen.progs@gmail.com> | 2021-01-28 21:41:01 +0100 |
---|---|---|
committer | pgen <p.gen.progs@gmail.com> | 2021-01-29 00:05:24 +0100 |
commit | d467d0cf093c7c3a628a8a790f34ac216d764392 (patch) | |
tree | 500bf76999e6c478da045ea6aac1525a336435bf /xmalloc.c | |
parent | 2416f3fc5ba9a40cf5e7f5558d2d49b32638ad1e (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.c | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -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. */ /* ================== */ |