The following function sets, modeled after the ANSI C standard, but specifying behavior when requesting zero bytes, are available for allocating and releasing memory from the Python heap:
|void *p, size_t n)|
The following type-oriented macros are provided for convenience. Note that TYPE refers to any C type.
|TYPE, size_t n)|
(n * sizeof(TYPE))bytes of memory. Returns a pointer cast to TYPE*. The memory will not have been initialized in any way.
|void *p, TYPE, size_t n)|
(n * sizeof(TYPE))bytes. Returns a pointer cast to TYPE*.
In addition, the following macro sets are provided for calling the Python memory allocator directly, without involving the C API functions listed above. However, note that their use does not preserve binary compatibility accross Python versions and is therefore deprecated in extension modules.
PyMem_MALLOC(), PyMem_REALLOC(), PyMem_FREE().
PyMem_NEW(), PyMem_RESIZE(), PyMem_DEL().
See About this document... for information on suggesting changes.