Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
39f59b08
Commit
39f59b08
authored
Nov 23, 2002
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove MALLOC_ZERO_RETURNS_NULL.
parent
19cf4ee6
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
5 additions
and
110 deletions
+5
-110
Include/pymem.h
Include/pymem.h
+4
-9
Objects/obmalloc.c
Objects/obmalloc.c
+0
-2
RISCOS/pyconfig.h
RISCOS/pyconfig.h
+0
-3
configure
configure
+1
-64
configure.in
configure.in
+0
-29
pyconfig.h.in
pyconfig.h.in
+0
-3
No files found.
Include/pymem.h
View file @
39f59b08
...
@@ -62,16 +62,11 @@ PyAPI_FUNC(void) PyMem_Free(void *);
...
@@ -62,16 +62,11 @@ PyAPI_FUNC(void) PyMem_Free(void *);
#else
/* ! PYMALLOC_DEBUG */
#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)
#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)
#define PyMem_REALLOC(p, n) realloc((p), (n) ? (n) : 1)
#endif
/* PYMALLOC_DEBUG */
#endif
/* PYMALLOC_DEBUG */
...
...
Objects/obmalloc.c
View file @
39f59b08
...
@@ -688,10 +688,8 @@ redirect:
...
@@ -688,10 +688,8 @@ redirect:
* last chance to serve the request) or when the max memory limit
* last chance to serve the request) or when the max memory limit
* has been reached.
* has been reached.
*/
*/
#ifdef MALLOC_ZERO_RETURNS_NULL
if
(
nbytes
==
0
)
if
(
nbytes
==
0
)
nbytes
=
1
;
nbytes
=
1
;
#endif
return
(
void
*
)
malloc
(
nbytes
);
return
(
void
*
)
malloc
(
nbytes
);
}
}
...
...
RISCOS/pyconfig.h
View file @
39f59b08
...
@@ -184,9 +184,6 @@
...
@@ -184,9 +184,6 @@
/* Define if nice() returns success/failure instead of the new priority. */
/* Define if nice() returns success/failure instead of the new priority. */
#undef HAVE_BROKEN_NICE
#undef HAVE_BROKEN_NICE
/* Define if malloc(0) returns a NULL pointer */
#undef MALLOC_ZERO_RETURNS_NULL
/* Define if you have POSIX threads */
/* Define if you have POSIX threads */
#undef _POSIX_THREADS
#undef _POSIX_THREADS
...
...
configure
View file @
39f59b08
#! /bin/sh
#! /bin/sh
# From configure.in Revision: 1.37
0
.
# From configure.in Revision: 1.37
1
.
# Guess values for system-dependent variables and create Makefiles.
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.53 for python 2.3.
# Generated by GNU Autoconf 2.53 for python 2.3.
#
#
...
@@ -15306,69 +15306,6 @@ done
...
@@ -15306,69 +15306,6 @@ done
LIBS
=
$LIBS_SAVE
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
# check for wchar.h
if
test
"
${
ac_cv_header_wchar_h
+set
}
"
=
set
;
then
if
test
"
${
ac_cv_header_wchar_h
+set
}
"
=
set
;
then
echo
"
$as_me
:
$LINENO
: checking for wchar.h"
>
&5
echo
"
$as_me
:
$LINENO
: checking for wchar.h"
>
&5
...
...
configure.in
View file @
39f59b08
...
@@ -2243,35 +2243,6 @@ LIBS="$LIBS $LIBM"
...
@@ -2243,35 +2243,6 @@ LIBS="$LIBS $LIBM"
AC_REPLACE_FUNCS(hypot)
AC_REPLACE_FUNCS(hypot)
LIBS=$LIBS_SAVE
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
# check for wchar.h
AC_CHECK_HEADER(wchar.h, [
AC_CHECK_HEADER(wchar.h, [
AC_DEFINE(HAVE_WCHAR_H, 1,
AC_DEFINE(HAVE_WCHAR_H, 1,
...
...
pyconfig.h.in
View file @
39f59b08
...
@@ -603,9 +603,6 @@
...
@@ -603,9 +603,6 @@
<sysmacros.h>. */
<sysmacros.h>. */
#undef MAJOR_IN_SYSMACROS
#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. */
/* Define if mvwdelch in curses.h is an expression. */
#undef MVWDELCH_IS_EXPRESSION
#undef MVWDELCH_IS_EXPRESSION
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment