Added Py_Malloc and friends as well as PyMem_Malloc and friends.

This commit is contained in:
Guido van Rossum 1997-08-05 01:59:22 +00:00
parent 5c159bd855
commit d085e88d3c
1 changed files with 19 additions and 2 deletions

View File

@ -58,8 +58,8 @@ PERFORMANCE OF THIS SOFTWARE.
#endif
#ifdef __cplusplus
// Move this down here since some C++ #include's don't like to be included
// inside an extern "C"
/* Move this down here since some C++ #include's don't like to be included
inside an extern "C" */
extern "C" {
#endif
@ -97,6 +97,23 @@ extern void free Py_PROTO((ANY *)); /* XXX sometimes int on Unix old systems */
#define PyMem_DEL(p) free((ANY *)p)
#define PyMem_XDEL(p) if ((p) == NULL) ; else PyMem_DEL(p)
/* Two sets of function wrappers around malloc and friends; useful if
you need to be sure that you are using the same memory allocator as
Python. Note that the wrappers make sure that allocating 0 bytes
returns a non-NULL pointer, even if the underlying malloc doesn't.
The Python interpreter continues to use PyMem_NEW etc. */
/* These wrappers around malloc call PyErr_NoMemory() on failure */
extern ANY *Py_Malloc Py_PROTO((size_t));
extern ANY *Py_Realloc Py_PROTO((ANY *, size_t));
extern void Py_Free Py_PROTO((ANY *));
/* These wrappers around malloc *don't* call anything on failure */
extern ANY *PyMem_Malloc Py_PROTO((size_t));
extern ANY *PyMem_Realloc Py_PROTO((ANY *, size_t));
extern void PyMem_Free Py_PROTO((ANY *));
#ifdef __cplusplus
}
#endif