]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
ac_cv_func_malloc_0_nonnull for malloc(0) check (#1351)
authorYorgos Thessalonikefs <yorgos@nlnetlabs.nl>
Mon, 29 Sep 2025 11:12:27 +0000 (13:12 +0200)
committerGitHub <noreply@github.com>
Mon, 29 Sep 2025 11:12:27 +0000 (13:12 +0200)
- For #1339, use the standard variable ac_cv_func_malloc_0_nonnull for
  the malloc(0) check during configure; patch from Helmut Grohne.

acx_nlnetlabs.m4
configure.ac

index 2005637a3333788f1718dc9d678382dcc4187f4f..c8195f5e1001073ad6cfa3d3fcc9293486b93af5 100644 (file)
@@ -2,7 +2,9 @@
 # Copyright 2009, Wouter Wijngaards, NLnet Labs.   
 # BSD licensed.
 #
-# Version 49
+# Version 50
+# 2025-09-29 add ac_cv_func_malloc_0_nonnull as a cache value for the malloc(0)
+#            check by ACX_FUNC_MALLOC.
 # 2025-09-29 add ACX_CHECK_NONSTRING_ATTRIBUTE, AHX_CONFIG_NONSTRING_ATTRIBUTE.
 # 2024-01-16 fix to add -l:libssp.a to -lcrypto link check.
 #           and check for getaddrinfo with only header.
@@ -1232,8 +1234,9 @@ dnl detect malloc and provide malloc compat prototype.
 dnl $1: unique name for compat code
 AC_DEFUN([ACX_FUNC_MALLOC],
 [
-       AC_MSG_CHECKING([for GNU libc compatible malloc])
-       AC_RUN_IFELSE([AC_LANG_PROGRAM(
+       AC_CACHE_CHECK([for GNU libc compatible malloc],[ac_cv_func_malloc_0_nonnull],
+       [
+               AC_RUN_IFELSE([AC_LANG_PROGRAM(
 [[#if defined STDC_HEADERS || defined HAVE_STDLIB_H
 #include <stdlib.h>
 #else
@@ -1241,14 +1244,16 @@ char *malloc ();
 #endif
 ]], [ if(malloc(0) != 0) return 1;])
 ],
-       [AC_MSG_RESULT([no])
-       AC_LIBOBJ(malloc)
-       AC_DEFINE_UNQUOTED([malloc], [rpl_malloc_$1], [Define if  replacement function should be used.])] ,
-       [AC_MSG_RESULT([yes])
-       AC_DEFINE([HAVE_MALLOC], 1, [If have GNU libc compatible malloc])],
-       [AC_MSG_RESULT([no (crosscompile)])
-       AC_LIBOBJ(malloc)
-       AC_DEFINE_UNQUOTED([malloc], [rpl_malloc_$1], [Define if  replacement function should be used.])] )
+               [ac_cv_func_malloc_0_nonnull=no],
+               [ac_cv_func_malloc_0_nonnull=yes],
+               [ac_cv_func_malloc_0_nonnull="no (crosscompile)"])
+       ])
+       AS_IF([test "$ac_cv_func_malloc_0_nonnull" = yes],
+               [AC_DEFINE([HAVE_MALLOC], 1, [If have GNU libc compatible malloc])],
+       [
+               AC_LIBOBJ(malloc)
+               AC_DEFINE_UNQUOTED([malloc], [rpl_malloc_$1], [Define if  replacement function should be used.])
+       ])
 ])
 
 dnl Define fallback for fseeko and ftello if needed.
index b5ff6717ff97b2b08b3e395e59d571fdf8314422..648040c6d56596caff2c416c7a73529fa288bbde 100644 (file)
@@ -635,19 +635,19 @@ AC_ARG_ENABLE(alloc-nonregional, AS_HELP_STRING([--enable-alloc-nonregional],[ e
 if test x_$enable_alloc_nonregional = x_yes; then
        AC_DEFINE(UNBOUND_ALLOC_NONREGIONAL, 1, [use malloc not regions, for debug use])
 fi
-if test x_$enable_alloc_checks = x_yes; then
+AS_IF([test x_$enable_alloc_checks = x_yes],[
        AC_DEFINE(UNBOUND_ALLOC_STATS, 1, [use statistics for allocs and frees, for debug use])
        SLDNS_ALLOCCHECK_EXTRA_OBJ="alloc.lo log.lo"
        AC_SUBST(SLDNS_ALLOCCHECK_EXTRA_OBJ)
        ASYNCLOOK_ALLOCCHECK_EXTRA_OBJ="alloc.lo"
        AC_SUBST(ASYNCLOOK_ALLOCCHECK_EXTRA_OBJ)
-else
-       if test x_$enable_alloc_lite = x_yes; then
+],[
+       AS_IF([test x_$enable_alloc_lite = x_yes],[
                AC_DEFINE(UNBOUND_ALLOC_LITE, 1, [use to enable lightweight alloc assertions, for debug use])
-       else
+       ],[
                ACX_FUNC_MALLOC([unbound])
-       fi
-fi
+       ])
+])
 
 # check windows threads (we use them, not pthreads, on windows).
 if test "$on_mingw" = "yes"; then