diff --git a/acinclude.m4 b/acinclude.m4 index cd204477f00cd5573cf6f9b338604fc825320196..99cd331a3c2ae18f46deb0ccab74ff808259070e 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -171,6 +171,57 @@ AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [ ]) +dnl CURL_CHECK_HEADER_MALLOC +dnl ------------------------------------------------- +dnl Check for compilable and valid malloc.h header, +dnl and check if it is needed even with stdlib.h + +AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [ + AC_CACHE_CHECK([for malloc.h], [ac_cv_header_malloc_h], [ + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([ +#include + ],[ + void *p = malloc(10); + void *q = calloc(10,10); + free(p); + free(q); + ]) + ],[ + ac_cv_header_malloc_h="yes" + ],[ + ac_cv_header_malloc_h="no" + ]) + ]) + if test "$ac_cv_header_malloc_h" = "yes"; then + AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1, + [Define to 1 if you have the malloc.h header file.]) + # + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([ +#include + ],[ + void *p = malloc(10); + void *q = calloc(10,10); + free(p); + free(q); + ]) + ],[ + curl_cv_need_header_malloc_h="no" + ],[ + curl_cv_need_header_malloc_h="yes" + ]) + # + case "$curl_cv_need_header_malloc_h" in + yes) + AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1, + [Define to 1 if you need the malloc.h header file.]) + ;; + esac + fi +]) + + dnl CURL_CHECK_TYPE_SOCKLEN_T dnl ------------------------------------------------- dnl Check for existing socklen_t type, and provide diff --git a/ares/acinclude.m4 b/ares/acinclude.m4 index 05739f1145c2f48552f1810434e05310202bab86..4db7a360dab4c64cba34230aec6f1255d6ecd613 100644 --- a/ares/acinclude.m4 +++ b/ares/acinclude.m4 @@ -149,6 +149,57 @@ AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [ ]) +dnl CURL_CHECK_HEADER_MALLOC +dnl ------------------------------------------------- +dnl Check for compilable and valid malloc.h header, +dnl and check if it is needed even with stdlib.h + +AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [ + AC_CACHE_CHECK([for malloc.h], [ac_cv_header_malloc_h], [ + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([ +#include + ],[ + void *p = malloc(10); + void *q = calloc(10,10); + free(p); + free(q); + ]) + ],[ + ac_cv_header_malloc_h="yes" + ],[ + ac_cv_header_malloc_h="no" + ]) + ]) + if test "$ac_cv_header_malloc_h" = "yes"; then + AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1, + [Define to 1 if you have the malloc.h header file.]) + # + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([ +#include + ],[ + void *p = malloc(10); + void *q = calloc(10,10); + free(p); + free(q); + ]) + ],[ + curl_cv_need_header_malloc_h="no" + ],[ + curl_cv_need_header_malloc_h="yes" + ]) + # + case "$curl_cv_need_header_malloc_h" in + yes) + AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1, + [Define to 1 if you need the malloc.h header file.]) + ;; + esac + fi +]) + + dnl CURL_CHECK_TYPE_SOCKLEN_T dnl ------------------------------------------------- dnl Check for existing socklen_t type, and provide diff --git a/ares/configure.ac b/ares/configure.ac index a59e701c5435c51c688673c7cb3cfbde0656778b..b331c33616688a3371d9b44a7e124d5382fe65f8 100644 --- a/ares/configure.ac +++ b/ares/configure.ac @@ -96,6 +96,8 @@ CURL_CHECK_HEADER_WINSOCK CURL_CHECK_HEADER_WINSOCK2 CURL_CHECK_HEADER_WS2TCPIP +CURL_CHECK_HEADER_MALLOC + dnl check for a few basic system headers we need AC_CHECK_HEADERS( sys/types.h \ diff --git a/configure.ac b/configure.ac index 7ce7b3d5f85186977c623001cd6d2170b50c8202..c5486a387b9a58a24e0a1ee2d9a41a2b546a2c81 100644 --- a/configure.ac +++ b/configure.ac @@ -1443,6 +1443,7 @@ dnl ********************************************************************** dnl Checks for header files. AC_HEADER_STDC +CURL_CHECK_HEADER_MALLOC dnl Now check for the very most basic headers. Then we can use these dnl ones as default-headers when checking for the rest! @@ -1454,7 +1455,6 @@ AC_CHECK_HEADERS( sys/ioctl.h \ assert.h \ unistd.h \ - malloc.h \ stdlib.h \ limits.h \ arpa/inet.h \