diff options
author | Darren Tucker <dtucker@zip.com.au> | 2017-09-27 07:44:41 +1000 |
---|---|---|
committer | Darren Tucker <dtucker@zip.com.au> | 2017-09-27 07:44:41 +1000 |
commit | 74c1c3660acf996d9dc329e819179418dc115f2c (patch) | |
tree | c8bbb5549b3f1a29ca7f81c9a21a099119d2049d /configure.ac | |
parent | 6a9481258a77b0b54b2a313d1761c87360c5f1f5 (diff) |
Check for and handle calloc(p, 0) = NULL.
On some platforms (AIX, maybe others) allocating zero bytes of memory
via the various *alloc functions returns NULL, which is permitted
by the standards. Autoconf has some macros for detecting this (with
the exception of calloc for some reason) so use these and if necessary
activate shims for them. ok djm@
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac index 545bee88..e9c593ac 100644 --- a/configure.ac +++ b/configure.ac @@ -1331,7 +1331,17 @@ AC_CHECK_FUNCS([fmt_scaled scan_scaled login logout openpty updwtmp logwtmp]) AC_SEARCH_LIBS([inet_ntop], [resolv nsl]) AC_SEARCH_LIBS([gethostbyname], [resolv nsl]) +# "Particular Function Checks" +# see https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Particular-Functions.html AC_FUNC_STRFTIME +AC_FUNC_MALLOC +AC_FUNC_REALLOC +# autoconf doesn't have AC_FUNC_CALLOC so fake it if malloc returns NULL; +if test "x$ac_cv_func_malloc_0_nonnull" != "xyes"; then + AC_DEFINE(HAVE_CALLOC, 0, [calloc(x, 0) returns NULL]) + AC_DEFINE(calloc, rpl_calloc, + [Define to rpl_calloc if the replacement function should be used.]) +fi # Check for ALTDIRFUNC glob() extension AC_MSG_CHECKING([for GLOB_ALTDIRFUNC support]) |