Allocates n bytes and returns a pointer of type void* to
the allocated memory, or NULL if the request fails. Requesting zero
bytes returns a non-NULL pointer.
The memory will not have been initialized in any way.
Resizes the memory block pointed to by p to n bytes. The
contents will be unchanged to the minimum of the old and the new
sizes. If p is NULL, the call is equivalent to
PyMem_Malloc(n); if n is equal to zero, the
memory block is resized but is not freed, and the returned pointer is
non-NULL. Unless p is NULL, it must have been returned by
a previous call to PyMem_Malloc() or
PyMem_Realloc().
Frees the memory block pointed to by p, which must have been
returned by a previous call to PyMem_Malloc() or
PyMem_Realloc(). Otherwise, or if
PyMem_Free(p) has been called before, undefined behaviour
occurs. If p is NULL, no operation is performed.
The following type-oriented macros are provided for convenience. Note
that TYPE refers to any C type.
Same as PyMem_Malloc(), but allocates (n *
sizeof(TYPE)) bytes of memory. Returns a pointer cast to
TYPE*.
The memory will not have been initialized in any way.
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.