1
0
mirror of https://github.com/moparisthebest/curl synced 2024-11-11 20:15:03 -05:00

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.
This commit is contained in:
Yang Tse 2009-04-21 10:26:58 +00:00
parent fe8eeb5641
commit 9770899a4b
23 changed files with 143 additions and 48 deletions

View File

@ -6,6 +6,11 @@
Changelog Changelog
Yang Tse (21 Apr 2009)
- 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.
Daniel Stenberg (20 Apr 2009) Daniel Stenberg (20 Apr 2009)
- Leanic Lefever reported a crash and did some detailed research on why and - Leanic Lefever reported a crash and did some detailed research on why and
how it occurs (http://curl.haxx.se/mail/lib-2009-04/0289.html). The how it occurs (http://curl.haxx.se/mail/lib-2009-04/0289.html). The

View File

@ -893,6 +893,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 CURL_CHECK_TYPE_SOCKLEN_T
dnl ------------------------------------------------- dnl -------------------------------------------------
dnl Check for existing socklen_t type, and provide dnl Check for existing socklen_t type, and provide

View File

@ -1,5 +1,10 @@
Changelog for the c-ares project 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) * March 11 2009 (Yang Tse)
- Japheth Cleaver fixed acountry.c replacing u_long with unsigned long. - Japheth Cleaver fixed acountry.c replacing u_long with unsigned long.

View File

@ -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 CURL_CHECK_TYPE_SOCKLEN_T
dnl ------------------------------------------------- dnl -------------------------------------------------
dnl Check for existing socklen_t type, and provide dnl Check for existing socklen_t type, and provide

View File

@ -1,7 +1,7 @@
/* $Id$ */ /* $Id$ */
/* Copyright 1998 by the Massachusetts Institute of Technology. /* 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 * Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without * software and its documentation for any purpose and without
@ -20,7 +20,6 @@
#if defined(WIN32) && !defined(WATT32) #if defined(WIN32) && !defined(WATT32)
#include <iphlpapi.h> #include <iphlpapi.h>
#include <malloc.h>
#endif #endif
#ifdef HAVE_SYS_PARAM_H #ifdef HAVE_SYS_PARAM_H

View File

@ -430,6 +430,7 @@ dnl Checks for header files.
AC_HEADER_STDC AC_HEADER_STDC
CURL_CHECK_HEADER_MALLOC CURL_CHECK_HEADER_MALLOC
CURL_CHECK_HEADER_MEMORY
dnl check for a few basic system headers we need dnl check for a few basic system headers we need
AC_CHECK_HEADERS( AC_CHECK_HEADERS(

View File

@ -42,6 +42,14 @@
#include <sys/types.h> #include <sys/types.h>
#endif #endif
#ifdef NEED_MALLOC_H
#include <malloc.h>
#endif
#ifdef NEED_MEMORY_H
#include <memory.h>
#endif
#ifdef HAVE_SYS_STAT_H #ifdef HAVE_SYS_STAT_H
#include <sys/stat.h> #include <sys/stat.h>
#endif #endif

View File

@ -1869,6 +1869,7 @@ dnl Checks for header files.
AC_HEADER_STDC AC_HEADER_STDC
CURL_CHECK_HEADER_MALLOC CURL_CHECK_HEADER_MALLOC
CURL_CHECK_HEADER_MEMORY
dnl Now check for the very most basic headers. Then we can use these dnl Now check for the very most basic headers. Then we can use these
dnl ones as default-headers when checking for the rest! dnl ones as default-headers when checking for the rest!

View File

@ -25,9 +25,6 @@
#include <curl/curl.h> #include <curl/curl.h>
#ifdef NEED_MALLOC_H
# include <malloc.h>
#endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h> # include <sys/socket.h>
#endif #endif

View File

@ -28,9 +28,6 @@
#ifdef HAVE_LIMITS_H #ifdef HAVE_LIMITS_H
#include <limits.h> #include <limits.h>
#endif #endif
#ifdef NEED_MALLOC_H
#include <malloc.h>
#endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> #include <sys/socket.h>
#endif #endif

View File

@ -25,9 +25,6 @@
#include <string.h> #include <string.h>
#ifdef NEED_MALLOC_H
#include <malloc.h>
#endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> #include <sys/socket.h>
#endif #endif

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -25,9 +25,6 @@
#include <string.h> #include <string.h>
#ifdef NEED_MALLOC_H
#include <malloc.h>
#endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> #include <sys/socket.h>
#endif #endif

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -26,9 +26,6 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#ifdef NEED_MALLOC_H
#include <malloc.h>
#endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> #include <sys/socket.h>
#endif #endif

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -25,9 +25,6 @@
#include <string.h> #include <string.h>
#ifdef NEED_MALLOC_H
#include <malloc.h>
#endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> #include <sys/socket.h>
#endif #endif

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -25,9 +25,6 @@
#include <string.h> #include <string.h>
#ifdef NEED_MALLOC_H
#include <malloc.h>
#endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> #include <sys/socket.h>
#endif #endif

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -26,9 +26,6 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#ifdef NEED_MALLOC_H
#include <malloc.h>
#endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> #include <sys/socket.h>
#endif #endif

View File

@ -30,9 +30,6 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h> #include <ctype.h>
#ifdef NEED_MALLOC_H
#include <malloc.h>
#endif
#include <errno.h> #include <errno.h>
#ifdef CURL_LDAP_HYBRID /* If W$ definitions are needed. */ #ifdef CURL_LDAP_HYBRID /* If W$ definitions are needed. */

View File

@ -8,7 +8,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -41,9 +41,6 @@
#include <sys/socket.h> #include <sys/socket.h>
#endif #endif
#include <stdio.h> #include <stdio.h>
#ifdef HAVE_MEMORY_H
#include <memory.h>
#endif
#define logfile curl_debuglogfile #define logfile curl_debuglogfile

View File

@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -49,6 +49,14 @@
#include <sys/types.h> #include <sys/types.h>
#endif #endif
#ifdef NEED_MALLOC_H
#include <malloc.h>
#endif
#ifdef NEED_MEMORY_H
#include <memory.h>
#endif
#ifdef HAVE_SYS_STAT_H #ifdef HAVE_SYS_STAT_H
#include <sys/stat.h> #include <sys/stat.h>
#endif #endif

View File

@ -26,9 +26,6 @@
#if !defined(CURL_DISABLE_PROXY) || defined(USE_WINDOWS_SSPI) #if !defined(CURL_DISABLE_PROXY) || defined(USE_WINDOWS_SSPI)
#include <string.h> #include <string.h>
#ifdef NEED_MALLOC_H
#include <malloc.h>
#endif
#ifdef HAVE_STDLIB_H #ifdef HAVE_STDLIB_H
#include <stdlib.h> #include <stdlib.h>
#endif #endif

View File

@ -34,9 +34,6 @@
#endif #endif
#include <string.h> #include <string.h>
#ifdef NEED_MALLOC_H
#include <malloc.h>
#endif
#ifdef HAVE_STDLIB_H #ifdef HAVE_STDLIB_H
#include <stdlib.h> #include <stdlib.h>
#endif #endif

View File

@ -28,9 +28,6 @@
#include <string.h> #include <string.h>
#ifdef NEED_MALLOC_H
#include <malloc.h>
#endif
#ifdef HAVE_STDLIB_H #ifdef HAVE_STDLIB_H
#include <stdlib.h> #include <stdlib.h>
#endif #endif

View File

@ -256,6 +256,9 @@
/* Define if you have the <memory.h> header file. */ /* Define if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1 #define HAVE_MEMORY_H 1
/* Define to 1 if you need the memory.h header file even with stdlib.h */
#define NEED_MEMORY_H 1
/* Define if you have the `sigsetjmp' function. */ /* Define if you have the `sigsetjmp' function. */
#define HAVE_SIGSETJMP 1 #define HAVE_SIGSETJMP 1