| |
| .. cfunction:: void* PyMem_Realloc(void *p, size_t n) |
| |
| 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 :cfunc:`PyMem_Malloc(n)`; else 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 |
n | to :cfunc:`PyMem_Malloc` or :cfunc:`PyMem_Realloc`. |
n | to :cfunc:`PyMem_Malloc` or :cfunc:`PyMem_Realloc`. If the request fails, |
| :cfunc:`PyMem_Realloc` returns *NULL* and *p* remains a valid pointer to the |
| previous memory area. |
| |
| |
| .. cfunction:: void PyMem_Free(void *p) |
| |
| Frees the memory block pointed to by *p*, which must have been returned by a |
| previous call to :cfunc:`PyMem_Malloc` or :cfunc:`PyMem_Realloc`. Otherwise, or |
| if :cfunc:`PyMem_Free(p)` has been called before, undefined behavior occurs. If |
| *p* is *NULL*, no operation is performed. |
| Same as :cfunc:`PyMem_Malloc`, but allocates ``(n * sizeof(TYPE))`` bytes of |
| memory. Returns a pointer cast to :ctype:`TYPE\*`. The memory will not have |
| been initialized in any way. |
| |
| |
| .. cfunction:: TYPE* PyMem_Resize(void *p, TYPE, size_t n) |
| |
| Same as :cfunc:`PyMem_Realloc`, but the memory block is resized to ``(n * |
t | sizeof(TYPE))`` bytes. Returns a pointer cast to :ctype:`TYPE\*`. |
t | sizeof(TYPE))`` bytes. Returns a pointer cast to :ctype:`TYPE\*`. On return, |
| *p* will be a pointer to the new memory area, or *NULL* in the event of |
| failure. This is a C preprocessor macro; p is always reassigned. Save |
| the original value of p to avoid losing memory when handling errors. |
| |
| |
| .. cfunction:: void PyMem_Del(void *p) |
| |
| Same as :cfunc:`PyMem_Free`. |
| |
| In addition, the following macro sets are provided for calling the Python memory |
| allocator directly, without involving the C API functions listed above. However, |