rest25/c-api/memory.rst => rest262/c-api/memory.rst
104
105.. cfunction:: void* PyMem_Realloc(void *p, size_t n)
106
107   Resizes the memory block pointed to by *p* to *n* bytes. The contents will be
108   unchanged to the minimum of the old and the new sizes. If *p* is *NULL*, the
109   call is equivalent to :cfunc:`PyMem_Malloc(n)`; else if *n* is equal to zero,
110   the memory block is resized but is not freed, and the returned pointer is
111   non-*NULL*.  Unless *p* is *NULL*, it must have been returned by a previous call
n112-   to :cfunc:`PyMem_Malloc` or :cfunc:`PyMem_Realloc`.
n112+   to :cfunc:`PyMem_Malloc` or :cfunc:`PyMem_Realloc`. If the request fails,
113+   :cfunc:`PyMem_Realloc` returns *NULL* and *p* remains a valid pointer to the
114+   previous memory area.
113
114
115.. cfunction:: void PyMem_Free(void *p)
116
117   Frees the memory block pointed to by *p*, which must have been returned by a
118   previous call to :cfunc:`PyMem_Malloc` or :cfunc:`PyMem_Realloc`.  Otherwise, or
119   if :cfunc:`PyMem_Free(p)` has been called before, undefined behavior occurs. If
120   *p* is *NULL*, no operation is performed.
128   Same as :cfunc:`PyMem_Malloc`, but allocates ``(n * sizeof(TYPE))`` bytes of
129   memory.  Returns a pointer cast to :ctype:`TYPE\*`.  The memory will not have
130   been initialized in any way.
131
132
133.. cfunction:: TYPE* PyMem_Resize(void *p, TYPE, size_t n)
134
135   Same as :cfunc:`PyMem_Realloc`, but the memory block is resized to ``(n *
t136-   sizeof(TYPE))`` bytes.  Returns a pointer cast to :ctype:`TYPE\*`.
t138+   sizeof(TYPE))`` bytes.  Returns a pointer cast to :ctype:`TYPE\*`. On return,
139+   *p* will be a pointer to the new memory area, or *NULL* in the event of
140+   failure.  This is a C preprocessor macro; p is always reassigned.  Save
141+   the original value of p to avoid losing memory when handling errors.
137
138
139.. cfunction:: void PyMem_Del(void *p)
140
141   Same as :cfunc:`PyMem_Free`.
142
143In addition, the following macro sets are provided for calling the Python memory
144allocator directly, without involving the C API functions listed above. However,
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op