[Python-checkins] r42801 - in python/trunk: Include/pyarena.h Python/pyarena.c

tim.peters python-checkins at python.org
Thu Mar 2 22:14:48 CET 2006


Author: tim.peters
Date: Thu Mar  2 22:14:45 2006
New Revision: 42801

Modified:
   python/trunk/Include/pyarena.h
   python/trunk/Python/pyarena.c
Log:
Added words about what PyArena_Malloc() does.


Modified: python/trunk/Include/pyarena.h
==============================================================================
--- python/trunk/Include/pyarena.h	(original)
+++ python/trunk/Include/pyarena.h	Thu Mar  2 22:14:45 2006
@@ -35,11 +35,23 @@
   PyAPI_FUNC(PyArena *) PyArena_New(void);
   PyAPI_FUNC(void) PyArena_Free(PyArena *);
 
-  PyAPI_FUNC(void *) PyArena_Malloc(PyArena *, size_t);
+  /* Mostly like malloc(), return the address of a block of memory spanning
+   * `size` bytes, or return NULL (without setting an exception) if enough
+   * new memory can't be obtained.  Unlike malloc(0), PyArena_Malloc() with
+   * size=0 does not guarantee to return a unique pointer (the pointer
+   * returned may equal one or more other pointers obtained from
+   * PyArena_Malloc()).
+   * Note that pointers obtained via PyArena_Malloc() must never be passed to
+   * the system free() or realloc(), or to any of Python's similar memory-
+   * management functions.  PyArena_Malloc()-obtained pointers remain valid
+   * until PyArena_Free(ar) is called, at which point all pointers obtained
+   * from the arena `ar` become invalid simultaneously.
+   */
+  PyAPI_FUNC(void *) PyArena_Malloc(PyArena *, size_t size);
 
-  /* This routines isn't a proper arena allocation routine.  It takes
-     a PyObject* and records it so that it can be DECREFed when the
-     arena is freed.
+  /* This routine isn't a proper arena allocation routine.  It takes
+   * a PyObject* and records it so that it can be DECREFed when the
+   * arena is freed.
    */
   PyAPI_FUNC(int) PyArena_AddPyObject(PyArena *, PyObject *);
 

Modified: python/trunk/Python/pyarena.c
==============================================================================
--- python/trunk/Python/pyarena.c	(original)
+++ python/trunk/Python/pyarena.c	Thu Mar  2 22:14:45 2006
@@ -150,7 +150,7 @@
                 arena->total_blocks++;
                 arena->total_block_size += arena->a_cur->ab_size;
                 if (arena->a_cur->ab_size > DEFAULT_BLOCK_SIZE)
-                  arena->total_big_blocks++;
+                        ++arena->total_big_blocks;
 #endif
 	}
 	return p;


More information about the Python-checkins mailing list