summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Include/pymem.h13
-rw-r--r--Objects/obmalloc.c2
-rw-r--r--RISCOS/pyconfig.h3
-rwxr-xr-xconfigure65
-rw-r--r--configure.in29
-rw-r--r--pyconfig.h.in3
6 files changed, 5 insertions, 110 deletions
diff --git a/Include/pymem.h b/Include/pymem.h
index 6b1105c..f8aef29 100644
--- a/Include/pymem.h
+++ b/Include/pymem.h
@@ -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 */
diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c
index a72d05a..cd85657 100644
--- a/Objects/obmalloc.c
+++ b/Objects/obmalloc.c
@@ -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);
}
diff --git a/RISCOS/pyconfig.h b/RISCOS/pyconfig.h
index e7c3484..7a5a13c 100644
--- a/RISCOS/pyconfig.h
+++ b/RISCOS/pyconfig.h
@@ -184,9 +184,6 @@
/* 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
diff --git a/configure b/configure
index c07fae9..2a8fa9a 100755
--- 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
diff --git a/configure.in b/configure.in
index ed744ea..7c86412 100644
--- a/configure.in
+++ b/configure.in
@@ -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,
diff --git a/pyconfig.h.in b/pyconfig.h.in
index b71ecb2..9503ea8 100644
--- a/pyconfig.h.in
+++ b/pyconfig.h.in
@@ -603,9 +603,6 @@
<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