]> granicus.if.org Git - python/commitdiff
Remove MALLOC_ZERO_RETURNS_NULL.
authorMartin v. Löwis <martin@v.loewis.de>
Sat, 23 Nov 2002 09:13:40 +0000 (09:13 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Sat, 23 Nov 2002 09:13:40 +0000 (09:13 +0000)
Include/pymem.h
Objects/obmalloc.c
RISCOS/pyconfig.h
configure
configure.in
pyconfig.h.in

index 6b1105ccf720a39deff835fcd5df6e5f24b69de7..f8aef2991bcebe17c7fd65431a0753b0a18aa1e9 100644 (file)
@@ -62,16 +62,11 @@ PyAPI_FUNC(void) PyMem_Free(void *);
 
 #else  /* ! PYMALLOC_DEBUG */
 
-#ifdef MALLOC_ZERO_RETURNS_NULL
+/* PyMem_MALLOC(0) means malloc(1). Some systems would return NULL
+   for malloc(0), which would be treated as an error. Some platforms
+   would return a pointer with no memory behind it, which would break
+   pymalloc. To solve these problems, allocate an extra byte. */
 #define PyMem_MALLOC(n)         malloc((n) ? (n) : 1)
-#else
-#define PyMem_MALLOC           malloc
-#endif
-
-/* Caution:  whether MALLOC_ZERO_RETURNS_NULL is #defined has nothing to
-   do with whether platform realloc(non-NULL, 0) normally frees the memory
-   or returns NULL.  Rather than introduce yet another config variation,
-   just make a realloc to 0 bytes act as if to 1 instead. */
 #define PyMem_REALLOC(p, n)     realloc((p), (n) ? (n) : 1)
 
 #endif /* PYMALLOC_DEBUG */
index a72d05aaf57713b0add0269af682456cb39aadcb..cd85657150b9ffa30a5086b6eb67adb276344db7 100644 (file)
@@ -688,10 +688,8 @@ redirect:
         * last chance to serve the request) or when the max memory limit
         * has been reached.
         */
-#ifdef MALLOC_ZERO_RETURNS_NULL
        if (nbytes == 0)
                nbytes = 1;
-#endif
        return (void *)malloc(nbytes);
 }
 
index e7c3484e0d9c180998985eba7e926fae957cb153..7a5a13ced4ef4f5c37a00db0388dc4ca3aadec8d 100644 (file)
 /* Define if nice() returns success/failure instead of the new priority. */
 #undef HAVE_BROKEN_NICE
 
-/* Define if malloc(0) returns a NULL pointer */
-#undef MALLOC_ZERO_RETURNS_NULL
-
 /* Define if you have POSIX threads */
 #undef _POSIX_THREADS
 
index c07fae90e8159bde57142cc94f1885cf3129eb58..2a8fa9aceaf2109b05aa4a19cb8931b893c7380e 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in Revision: 1.370 .
+# From configure.in Revision: 1.371 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.53 for python 2.3.
 #
@@ -15306,69 +15306,6 @@ done
 
 LIBS=$LIBS_SAVE
 
-# check whether malloc(0) returns NULL or not
-echo "$as_me:$LINENO: checking what malloc(0) returns" >&5
-echo $ECHO_N "checking what malloc(0) returns... $ECHO_C" >&6
-if test "${ac_cv_malloc_zero+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test "$cross_compiling" = yes; then
-  ac_cv_malloc_zero=nonnull
-else
-  cat >conftest.$ac_ext <<_ACEOF
-#line $LINENO "configure"
-#include "confdefs.h"
-#include <stdio.h>
-#ifdef HAVE_STDLIB
-#include <stdlib.h>
-#else
-char *malloc(), *realloc();
-int *free();
-#endif
-main() {
-       char *p;
-       p = malloc(0);
-       if (p == NULL) exit(1);
-       p = realloc(p, 0);
-       if (p == NULL) exit(1);
-       free(p);
-       exit(0);
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_malloc_zero=nonnull
-else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-( exit $ac_status )
-ac_cv_malloc_zero=null
-fi
-rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-fi
- # XXX arm cross-compile?
-echo "$as_me:$LINENO: result: $ac_cv_malloc_zero" >&5
-echo "${ECHO_T}$ac_cv_malloc_zero" >&6
-if test "$ac_cv_malloc_zero" = null
-then
-
-cat >>confdefs.h <<\_ACEOF
-#define MALLOC_ZERO_RETURNS_NULL 1
-_ACEOF
-
-fi
-
 # check for wchar.h
 if test "${ac_cv_header_wchar_h+set}" = set; then
   echo "$as_me:$LINENO: checking for wchar.h" >&5
index ed744eae943f73e38349aa7995c40eda0183bd3d..7c86412b2cb4fe0efa8dff79bf023f1ee4d10702 100644 (file)
@@ -2243,35 +2243,6 @@ LIBS="$LIBS $LIBM"
 AC_REPLACE_FUNCS(hypot)
 LIBS=$LIBS_SAVE
 
-# check whether malloc(0) returns NULL or not
-AC_MSG_CHECKING(what malloc(0) returns)
-AC_CACHE_VAL(ac_cv_malloc_zero,
-[AC_TRY_RUN([#include <stdio.h>
-#ifdef HAVE_STDLIB
-#include <stdlib.h>
-#else
-char *malloc(), *realloc();
-int *free();
-#endif
-main() {
-       char *p;
-       p = malloc(0);
-       if (p == NULL) exit(1);
-       p = realloc(p, 0);
-       if (p == NULL) exit(1);
-       free(p);
-       exit(0);
-}],
-ac_cv_malloc_zero=nonnull,
-ac_cv_malloc_zero=null,
-ac_cv_malloc_zero=nonnull)]) # XXX arm cross-compile?
-AC_MSG_RESULT($ac_cv_malloc_zero)
-if test "$ac_cv_malloc_zero" = null
-then
-  AC_DEFINE(MALLOC_ZERO_RETURNS_NULL, 1,
-  [Define if malloc(0) returns a NULL pointer.])
-fi
-
 # check for wchar.h
 AC_CHECK_HEADER(wchar.h, [
   AC_DEFINE(HAVE_WCHAR_H, 1, 
index b71ecb2e5c5ae981aca9bf4b7ab34c75c948a1bd..9503ea81ab3e84e298925c960be1803845cb5450 100644 (file)
    <sysmacros.h>. */
 #undef MAJOR_IN_SYSMACROS
 
-/* Define if malloc(0) returns a NULL pointer. */
-#undef MALLOC_ZERO_RETURNS_NULL
-
 /* Define if mvwdelch in curses.h is an expression. */
 #undef MVWDELCH_IS_EXPRESSION