summaryrefslogtreecommitdiffstats
path: root/Include/pyport.h
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2002-04-12 07:22:56 (GMT)
committerTim Peters <tim.peters@gmail.com>2002-04-12 07:22:56 (GMT)
commitaf3e8de580ba756e820171253a5b580318914b79 (patch)
tree3bb909464364789e6fc22a1c2921246488b9d68c /Include/pyport.h
parente9e7452505ddf0ab68ed1f63aa6a19963137c2df (diff)
downloadcpython-af3e8de580ba756e820171253a5b580318914b79.zip
cpython-af3e8de580ba756e820171253a5b580318914b79.tar.gz
cpython-af3e8de580ba756e820171253a5b580318914b79.tar.bz2
First stab at rationalizing the PyMem_ API. Mixing PyObject_xyz with
PyMem_{Del, DEL} doesn't work yet (compilation problems). pyport.h: _PyMem_EXTRA is gone. pmem.h: Repaired comments. PyMem_{Malloc, MALLOC} and PyMem_{Realloc, REALLOC} now make the same x-platform guarantees when asking for 0 bytes, and when passing a NULL pointer to the latter. object.c: PyMem_{Malloc, Realloc} just call their macro versions now, since the latter take care of the x-platform 0 and NULL stuff by themselves now. pypcre.c, grow_stack(): So sue me. On two lines, this called PyMem_RESIZE to grow a "const" area. It's not legit to realloc a const area, so the compiler warned given the new expansion of PyMem_RESIZE. It would have gotten the same warning before if it had used PyMem_Resize() instead; the older macro version, but not the function version, silently cast away the constness. IMO that was a wrong thing to do, and the docs say the macro versions of PyMem_xyz are deprecated anyway. If somebody else is resizing const areas with the macro spelling, they'll get a warning when they recompile now too.
Diffstat (limited to 'Include/pyport.h')
-rw-r--r--Include/pyport.h22
1 files changed, 0 insertions, 22 deletions
diff --git a/Include/pyport.h b/Include/pyport.h
index 86bbab2..790c7af 100644
--- a/Include/pyport.h
+++ b/Include/pyport.h
@@ -384,32 +384,10 @@ extern int fsync(int fd);
extern double hypot(double, double);
#endif
-
-/************************************
- * MALLOC COMPATIBILITY FOR pymem.h *
- ************************************/
-
#ifndef DL_IMPORT /* declarations for DLL import */
#define DL_IMPORT(RTYPE) RTYPE
#endif
-#ifdef MALLOC_ZERO_RETURNS_NULL
-/* Allocate an extra byte if the platform malloc(0) returns NULL.
- Caution: this bears no relation to whether realloc(p, 0) returns NULL
- when p != NULL. Even on platforms where malloc(0) does not return NULL,
- realloc(p, 0) may act like free(p) and return NULL. Examples include
- Windows, and Python's own obmalloc.c (as of 2-Mar-2002). For whatever
- reason, our docs promise that PyMem_Realloc(p, 0) won't act like
- free(p) or return NULL, so realloc() calls may have to be hacked
- too, but MALLOC_ZERO_RETURNS_NULL's state is irrelevant to realloc (it
- needs a different hack).
-*/
-#define _PyMem_EXTRA 1
-#else
-#define _PyMem_EXTRA 0
-#endif
-
-
/* If the fd manipulation macros aren't defined,
here is a set that should do the job */