Skip to content

Commit

Permalink
Minor clarification about what's actually promised for PyMem_Malloc(0).
Browse files Browse the repository at this point in the history
I probably didn't do a correct thing for the LaTeX spelling of the
integer 1.
  • Loading branch information
tim-one committed Apr 6, 2002
1 parent 303d05d commit 87bbdd3
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions Doc/api/memory.tex
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ \section{Overview \label{memoryOverview}}

It is important to understand that the management of the Python heap
is performed by the interpreter itself and that the user has no
control on it, even if she regularly manipulates object pointers to
control over it, even if she regularly manipulates object pointers to
memory blocks inside that heap. The allocation of heap space for
Python objects and other internal buffers is performed on demand by
the Python memory manager through the Python/C API functions listed in
Expand Down Expand Up @@ -79,22 +79,24 @@ \section{Overview \label{memoryOverview}}

\section{Memory Interface \label{memoryInterface}}

The following function sets, modeled after the ANSI C standard, are
available for allocating and releasing memory from the Python heap:
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:


\begin{cfuncdesc}{void*}{PyMem_Malloc}{size_t n}
Allocates \var{n} bytes and returns a pointer of type \ctype{void*}
to the allocated memory, or \NULL{} if the request fails.
Requesting zero bytes returns a non-\NULL{} pointer.
Requesting zero bytes returns a distinct non-\NULL{} pointer if
possible, as if \cfunction{PyMem_Malloc(1)} had been called instead.
The memory will not have been initialized in any way.
\end{cfuncdesc}

\begin{cfuncdesc}{void*}{PyMem_Realloc}{void *p, size_t n}
Resizes the memory block pointed to by \var{p} to \var{n} bytes.
The contents will be unchanged to the minimum of the old and the new
sizes. If \var{p} is \NULL, the call is equivalent to
\cfunction{PyMem_Malloc(\var{n})}; if \var{n} is equal to zero, the
\cfunction{PyMem_Malloc(\var{n})}; else if \var{n} is equal to zero, the
memory block is resized but is not freed, and the returned pointer
is non-\NULL. Unless \var{p} is \NULL, it must have been
returned by a previous call to \cfunction{PyMem_Malloc()} or
Expand All @@ -106,7 +108,7 @@ \section{Memory Interface \label{memoryInterface}}
returned by a previous call to \cfunction{PyMem_Malloc()} or
\cfunction{PyMem_Realloc()}. Otherwise, or if
\cfunction{PyMem_Free(p)} has been called before, undefined
behaviour occurs. If \var{p} is \NULL, no operation is performed.
behavior occurs. If \var{p} is \NULL, no operation is performed.
\end{cfuncdesc}

The following type-oriented macros are provided for convenience. Note
Expand Down

0 comments on commit 87bbdd3

Please sign in to comment.