diff options
author | Guido van Rossum <guido@python.org> | 1997-08-05 01:59:22 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1997-08-05 01:59:22 (GMT) |
commit | d085e88d3cb826fb144d4ca7544d247680d7a241 (patch) | |
tree | d1b923270fc4576aa5a1eaa1b14f3e7b25e1d2db /Include/mymalloc.h | |
parent | 5c159bd855514738fc3e233432cb30a5f4b55edb (diff) | |
download | cpython-d085e88d3cb826fb144d4ca7544d247680d7a241.zip cpython-d085e88d3cb826fb144d4ca7544d247680d7a241.tar.gz cpython-d085e88d3cb826fb144d4ca7544d247680d7a241.tar.bz2 |
Added Py_Malloc and friends as well as PyMem_Malloc and friends.
Diffstat (limited to 'Include/mymalloc.h')
-rw-r--r-- | Include/mymalloc.h | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/Include/mymalloc.h b/Include/mymalloc.h index 944a4dd..e55fe7b 100644 --- a/Include/mymalloc.h +++ b/Include/mymalloc.h @@ -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 |