Mailing List Archive

python/dist/src/Include pgenheaders.h,2.27,2.28 pymem.h,2.13,2.14
Update of /cvsroot/python/python/dist/src/Include
In directory usw-pr-cvs1:/tmp/cvs-serv24773/python/Include

Modified Files:
pgenheaders.h pymem.h
Log Message:
Moving pymalloc along.

+ Redirect PyMem_{Del, DEL} to the object allocator's free() when
pymalloc is enabled. Needed so old extensions can continue to
mix PyObject_New with PyMem_DEL.

+ This implies that pgen needs to be able to see the PyObject_XYZ
declarations too. pgenheaders.h now includes Python.h. An
implication is that I expect obmalloc.o needs to get linked into
pgen on non-Windows boxes.

+ When PYMALLOC_DEBUG is defined, *all* Py memory API functions
now funnel through the debug allocator wrapper around pymalloc.
This is the default in a debug build.

+ That caused compile.c to fail: it indirectly mixed PyMem_Malloc
with raw platform free() in one place. This is verbotten.


Index: pgenheaders.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/pgenheaders.h,v
retrieving revision 2.27
retrieving revision 2.28
diff -C2 -d -r2.27 -r2.28
*** pgenheaders.h 23 Oct 2001 02:18:35 -0000 2.27
--- pgenheaders.h 22 Apr 2002 02:33:27 -0000 2.28
***************
*** 8,28 ****
/* Include files and extern declarations used by most of the parser. */

! #include "pyconfig.h"
!
! /* pyconfig.h may or may not define DL_IMPORT */
! #ifndef DL_IMPORT /* declarations for DLL import/export */
! #define DL_IMPORT(RTYPE) RTYPE
! #endif
!
! #include <stdio.h>
! #include <string.h>
!
! #ifdef HAVE_STDLIB_H
! #include <stdlib.h>
! #endif
!
! #include "pymem.h"
!
! #include "pydebug.h"

DL_IMPORT(void) PySys_WriteStdout(const char *format, ...)
--- 8,12 ----
/* Include files and extern declarations used by most of the parser. */

! #include "Python.h"

DL_IMPORT(void) PySys_WriteStdout(const char *format, ...)

Index: pymem.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/pymem.h,v
retrieving revision 2.13
retrieving revision 2.14
diff -C2 -d -r2.13 -r2.14
*** pymem.h 12 Apr 2002 07:22:56 -0000 2.13
--- pymem.h 22 Apr 2002 02:33:27 -0000 2.14
***************
*** 53,57 ****

/* Macros. */
! #ifndef PyMem_MALLOC
#ifdef MALLOC_ZERO_RETURNS_NULL
#define PyMem_MALLOC(n) malloc((n) ? (n) : 1)
--- 53,64 ----

/* Macros. */
! #ifdef PYMALLOC_DEBUG
! /* Redirect all memory operations to Python's debugging allocator. */
! #define PyMem_MALLOC PyObject_MALLOC
! #define PyMem_REALLOC PyObject_REALLOC
! #define PyMem_FREE PyObject_FREE
!
! #else /* ! PYMALLOC_DEBUG */
!
#ifdef MALLOC_ZERO_RETURNS_NULL
#define PyMem_MALLOC(n) malloc((n) ? (n) : 1)
***************
*** 59,63 ****
#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
--- 66,69 ----
***************
*** 67,71 ****

#define PyMem_FREE free
! #endif /* PyMem_MALLOC */

/*
--- 73,77 ----

#define PyMem_FREE free
! #endif /* PYMALLOC_DEBUG */

/*
***************
*** 86,95 ****
PyMem_{Del, DEL} (there was no choice about this in 1.5.2), the latter
have to be redirected to the object allocator. */
- /* XXX The parser module needs rework before this can be enabled. */
- #if 0
#define PyMem_Del PyObject_Free
- #else
- #define PyMem_Del PyMem_Free
- #endif

/* Macros */
--- 92,96 ----
***************
*** 99,108 ****
( (p) = (type *) PyMem_REALLOC((p), (n) * sizeof(type)) )

- /* XXX The parser module needs rework before this can be enabled. */
- #if 0
#define PyMem_DEL PyObject_FREE
- #else
- #define PyMem_DEL PyMem_FREE
- #endif

#ifdef __cplusplus
--- 100,104 ----