diff options
author | Yang Tse <yangsita@gmail.com> | 2009-04-21 10:26:58 +0000 |
---|---|---|
committer | Yang Tse <yangsita@gmail.com> | 2009-04-21 10:26:58 +0000 |
commit | 9770899a4bfb27ea73d0b0ee4be857ea1e47c4fd (patch) | |
tree | 7966686f758d2545de81b434aa530d7f4bfe9094 /ares | |
parent | fe8eeb5641b488f6a730dd8afd34e589edb9b2c3 (diff) |
Moved potential inclusion of system's malloc.h and memory.h header files to
setup_once.h. Inclusion of each header file is based on the definition of
NEED_MALLOC_H and NEED_MEMORY_H respectively.
Diffstat (limited to 'ares')
-rw-r--r-- | ares/CHANGES | 5 | ||||
-rw-r--r-- | ares/acinclude.m4 | 52 | ||||
-rw-r--r-- | ares/ares_init.c | 3 | ||||
-rw-r--r-- | ares/configure.ac | 1 | ||||
-rw-r--r-- | ares/setup_once.h | 8 |
5 files changed, 67 insertions, 2 deletions
diff --git a/ares/CHANGES b/ares/CHANGES index 90ee71113..3fe0cf836 100644 --- a/ares/CHANGES +++ b/ares/CHANGES @@ -1,5 +1,10 @@ Changelog for the c-ares project +* April 21 2009 (Yang Tse) +- Moved potential inclusion of system's malloc.h and memory.h header files to + setup_once.h. Inclusion of each header file is based on the definition of + NEED_MALLOC_H and NEED_MEMORY_H respectively. + * March 11 2009 (Yang Tse) - Japheth Cleaver fixed acountry.c replacing u_long with unsigned long. diff --git a/ares/acinclude.m4 b/ares/acinclude.m4 index 879643dc4..790d1c74b 100644 --- a/ares/acinclude.m4 +++ b/ares/acinclude.m4 @@ -360,6 +360,58 @@ AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [ ]) +dnl CURL_CHECK_HEADER_MEMORY +dnl ------------------------------------------------- +dnl Check for compilable and valid memory.h header, +dnl and check if it is needed even with stdlib.h for +dnl memory related functions. + +AC_DEFUN([CURL_CHECK_HEADER_MEMORY], [ + AC_CACHE_CHECK([for memory.h], [ac_cv_header_memory_h], [ + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ +#include <memory.h> + ]],[[ + void *p = malloc(10); + void *q = calloc(10,10); + free(p); + free(q); + ]]) + ],[ + ac_cv_header_memory_h="yes" + ],[ + ac_cv_header_memory_h="no" + ]) + ]) + if test "$ac_cv_header_memory_h" = "yes"; then + AC_DEFINE_UNQUOTED(HAVE_MEMORY_H, 1, + [Define to 1 if you have the memory.h header file.]) + # + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ +#include <stdlib.h> + ]],[[ + void *p = malloc(10); + void *q = calloc(10,10); + free(p); + free(q); + ]]) + ],[ + curl_cv_need_header_memory_h="no" + ],[ + curl_cv_need_header_memory_h="yes" + ]) + # + case "$curl_cv_need_header_memory_h" in + yes) + AC_DEFINE_UNQUOTED(NEED_MEMORY_H, 1, + [Define to 1 if you need the memory.h header file even with stdlib.h]) + ;; + esac + fi +]) + + dnl CURL_CHECK_TYPE_SOCKLEN_T dnl ------------------------------------------------- dnl Check for existing socklen_t type, and provide diff --git a/ares/ares_init.c b/ares/ares_init.c index e8d9ab1d0..635efceed 100644 --- a/ares/ares_init.c +++ b/ares/ares_init.c @@ -1,7 +1,7 @@ /* $Id$ */ /* Copyright 1998 by the Massachusetts Institute of Technology. - * Copyright (C) 2007-2008 by Daniel Stenberg + * Copyright (C) 2007-2009 by Daniel Stenberg * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without @@ -20,7 +20,6 @@ #if defined(WIN32) && !defined(WATT32) #include <iphlpapi.h> -#include <malloc.h> #endif #ifdef HAVE_SYS_PARAM_H diff --git a/ares/configure.ac b/ares/configure.ac index 67dc00771..aca5e9408 100644 --- a/ares/configure.ac +++ b/ares/configure.ac @@ -430,6 +430,7 @@ dnl Checks for header files. AC_HEADER_STDC CURL_CHECK_HEADER_MALLOC +CURL_CHECK_HEADER_MEMORY dnl check for a few basic system headers we need AC_CHECK_HEADERS( diff --git a/ares/setup_once.h b/ares/setup_once.h index 4f88d9994..bd5eba393 100644 --- a/ares/setup_once.h +++ b/ares/setup_once.h @@ -42,6 +42,14 @@ #include <sys/types.h> #endif +#ifdef NEED_MALLOC_H +#include <malloc.h> +#endif + +#ifdef NEED_MEMORY_H +#include <memory.h> +#endif + #ifdef HAVE_SYS_STAT_H #include <sys/stat.h> #endif |