diff options
author | Eric Andersen <andersen@codepoet.org> | 2003-05-23 06:42:53 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2003-05-23 06:42:53 +0000 |
commit | 9389fe19a3ab19e3c15cb3e370f5ae2f8380484a (patch) | |
tree | 34522d2e4afe93be56158f255395e7a9317dc096 | |
parent | a8938c2781a66b386eb0807f9149b871d03f4c6e (diff) |
Cope with autoconf's broken AC_FUNC_MALLOC macro, which redefines malloc as
rpl_malloc if it does not detect glibc style
returning-a-valid-pointer-for-malloc(0) behavior. This wrapper calls malloc()
as usual, but if N is zero, we allocate and return a 1-byte block instead....
sigh...
-Erik
-rw-r--r-- | include/stdlib.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/stdlib.h b/include/stdlib.h index a8a83a03c..bc9cd6224 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -547,6 +547,18 @@ extern void *malloc (size_t __size) __THROW __attribute_malloc__; /* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */ extern void *calloc (size_t __nmemb, size_t __size) __THROW __attribute_malloc__; +/* Cope with autoconf's broken AC_FUNC_MALLOC macro, which + * redefines malloc to rpl_malloc if it does not detect glibc + * style returning-a-valid-pointer-for-malloc(0) behavior. This + * calls malloc() as usual, but if N is zero, we allocate and + * return a 1-byte block instead.... sigh... */ +static inline char * rpl_malloc (size_t N) +{ + if (N == 0) { + N++; + } + return malloc (N); +} #endif #ifndef __need_malloc_and_calloc |