@@ -26,7 +26,7 @@ \section{Overview \label{memoryOverview}}
2626
2727It is important to understand that the management of the Python heap
2828is performed by the interpreter itself and that the user has no
29- control on it, even if she regularly manipulates object pointers to
29+ control over it, even if she regularly manipulates object pointers to
3030memory blocks inside that heap. The allocation of heap space for
3131Python objects and other internal buffers is performed on demand by
3232the Python memory manager through the Python/C API functions listed in
@@ -79,22 +79,24 @@ \section{Overview \label{memoryOverview}}
7979
8080\section {Memory Interface \label {memoryInterface } }
8181
82- The following function sets, modeled after the ANSI C standard, are
83- available for allocating and releasing memory from the Python heap:
82+ The following function sets, modeled after the ANSI C standard,
83+ but specifying behavior when requesting zero bytes,
84+ are available for allocating and releasing memory from the Python heap:
8485
8586
8687\begin {cfuncdesc }{void*}{PyMem_Malloc}{size_t n}
8788 Allocates \var {n} bytes and returns a pointer of type \ctype {void*}
8889 to the allocated memory, or \NULL {} if the request fails.
89- Requesting zero bytes returns a non-\NULL {} pointer.
90+ Requesting zero bytes returns a distinct non-\NULL {} pointer if
91+ possible, as if \cfunction {PyMem_Malloc(1)} had been called instead.
9092 The memory will not have been initialized in any way.
9193\end {cfuncdesc }
9294
9395\begin {cfuncdesc }{void*}{PyMem_Realloc}{void *p, size_t n}
9496 Resizes the memory block pointed to by \var {p} to \var {n} bytes.
9597 The contents will be unchanged to the minimum of the old and the new
9698 sizes. If \var {p} is \NULL , the call is equivalent to
97- \cfunction {PyMem_Malloc(\var {n})}; if \var {n} is equal to zero, the
99+ \cfunction {PyMem_Malloc(\var {n})}; else if \var {n} is equal to zero, the
98100 memory block is resized but is not freed, and the returned pointer
99101 is non-\NULL . Unless \var {p} is \NULL , it must have been
100102 returned by a previous call to \cfunction {PyMem_Malloc()} or
@@ -106,7 +108,7 @@ \section{Memory Interface \label{memoryInterface}}
106108 returned by a previous call to \cfunction {PyMem_Malloc()} or
107109 \cfunction {PyMem_Realloc()}. Otherwise, or if
108110 \cfunction {PyMem_Free(p)} has been called before, undefined
109- behaviour occurs. If \var {p} is \NULL , no operation is performed.
111+ behavior occurs. If \var {p} is \NULL , no operation is performed.
110112\end {cfuncdesc }
111113
112114The following type-oriented macros are provided for convenience. Note
0 commit comments