Remove MALLOC_ZERO_RETURNS_NULL.

This commit is contained in:
Martin v. Löwis 2002-11-23 09:13:40 +00:00
parent 19cf4ee69d
commit 39f59b089d
6 changed files with 5 additions and 110 deletions

View 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 */

View file

@ -688,10 +688,8 @@ PyObject_Malloc(size_t nbytes)
* 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);
}

View file

@ -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

65
configure vendored
View file

@ -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

View 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,

View file

@ -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