[Python-checkins] peps: PEP 445

victor.stinner python-checkins at python.org
Tue Jun 18 22:18:35 CEST 2013


http://hg.python.org/peps/rev/4c100be61da0
changeset:   4946:4c100be61da0
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Tue Jun 18 22:18:21 2013 +0200
summary:
  PEP 445

files:
  pep-0445.txt |  19 ++++++++++++-------
  1 files changed, 12 insertions(+), 7 deletions(-)


diff --git a/pep-0445.txt b/pep-0445.txt
--- a/pep-0445.txt
+++ b/pep-0445.txt
@@ -73,6 +73,7 @@
 
   - ``void PyMem_GetRawAllocator(PyMemBlockAllocator *allocator)``
   - ``void PyMem_SetRawAllocator(PyMemBlockAllocator *allocator)``
+  - default allocator: ``malloc()``, ``realloc()``, ``free()``
 
 * Add new functions to get and set internal functions of
   ``PyMem_Malloc()``, ``PyMem_Realloc()`` and ``PyMem_Free()``:
@@ -81,15 +82,19 @@
   - ``void PyMem_SetAllocator(PyMemBlockAllocator *allocator)``
   - ``malloc(ctx, 0)`` and ``realloc(ctx, ptr, 0)`` must not return
     *NULL*: it would be treated as an error.
+  - default allocator: ``malloc()``, ``realloc()``, ``free()``;
+    ``PyMem_Malloc(0)`` calls ``malloc(1)``
+    and ``PyMem_Realloc(NULL, 0)`` calls ``realloc(NULL, 1)``
 
 * Add new functions to get and set internal functions of
-  ``PyObject_Malloc()``,, ``PyObject_Realloc()`` and
+  ``PyObject_Malloc()``, ``PyObject_Realloc()`` and
   ``PyObject_Free()``:
 
   - ``void PyObject_GetAllocator(PyMemBlockAllocator *allocator)``
   - ``void PyObject_SetAllocator(PyMemBlockAllocator *allocator)``
   - ``malloc(ctx, 0)`` and ``realloc(ctx, ptr, 0)`` must not return
     *NULL*: it would be treated as an error.
+  - default allocator: the *pymalloc* allocator
 
 * Add a new ``PyMemMappingAllocator`` structure::
 
@@ -116,11 +121,14 @@
   allocators are replaced:
 
   - ``void PyMem_SetupDebugHooks(void)``
+  - the function does nothing is Python is compiled not compiled in
+    debug mode
 
 * The following memory allocators always returns *NULL* if size is
-  greater than ``PY_SSIZE_T_MAX``: ``PyMem_RawMalloc()``,
-  ``PyMem_RawRealloc()``, ``PyMem_Malloc()``, ``PyMem_Realloc()``,
-  ``PyObject_Malloc()``, ``PyObject_Realloc()``.
+  greater than ``PY_SSIZE_T_MAX`` (check before calling the internal
+  function): ``PyMem_RawMalloc()``, ``PyMem_RawRealloc()``,
+  ``PyMem_Malloc()``, ``PyMem_Realloc()``, ``PyObject_Malloc()``,
+  ``PyObject_Realloc()``.
 
 The builtin Python debug hooks were introduced in Python 2.3 and
 implement the following checks:
@@ -132,9 +140,6 @@
 * Detect write before the start of the buffer (buffer underflow)
 * Detect write after the end of the buffer (buffer overflow)
 
-The *pymalloc* allocator is used by default for:
-``PyObject_Malloc()``, ``PyObject_Realloc()`` and ``PyObject_Free()``.
-
 
 Make usage of these new APIs
 ----------------------------

-- 
Repository URL: http://hg.python.org/peps


More information about the Python-checkins mailing list