annotate DEPENDENCIES/mingw32/Python27/include/pyarena.h @ 118:770eb830ec19 emscripten

Typo fix
author Chris Cannam
date Wed, 18 May 2016 16:14:08 +0100
parents 2a2c65a20a8b
children
rev   line source
Chris@87 1 /* An arena-like memory interface for the compiler.
Chris@87 2 */
Chris@87 3
Chris@87 4 #ifndef Py_PYARENA_H
Chris@87 5 #define Py_PYARENA_H
Chris@87 6
Chris@87 7 #ifdef __cplusplus
Chris@87 8 extern "C" {
Chris@87 9 #endif
Chris@87 10
Chris@87 11 typedef struct _arena PyArena;
Chris@87 12
Chris@87 13 /* PyArena_New() and PyArena_Free() create a new arena and free it,
Chris@87 14 respectively. Once an arena has been created, it can be used
Chris@87 15 to allocate memory via PyArena_Malloc(). Pointers to PyObject can
Chris@87 16 also be registered with the arena via PyArena_AddPyObject(), and the
Chris@87 17 arena will ensure that the PyObjects stay alive at least until
Chris@87 18 PyArena_Free() is called. When an arena is freed, all the memory it
Chris@87 19 allocated is freed, the arena releases internal references to registered
Chris@87 20 PyObject*, and none of its pointers are valid.
Chris@87 21 XXX (tim) What does "none of its pointers are valid" mean? Does it
Chris@87 22 XXX mean that pointers previously obtained via PyArena_Malloc() are
Chris@87 23 XXX no longer valid? (That's clearly true, but not sure that's what
Chris@87 24 XXX the text is trying to say.)
Chris@87 25
Chris@87 26 PyArena_New() returns an arena pointer. On error, it
Chris@87 27 returns a negative number and sets an exception.
Chris@87 28 XXX (tim): Not true. On error, PyArena_New() actually returns NULL,
Chris@87 29 XXX and looks like it may or may not set an exception (e.g., if the
Chris@87 30 XXX internal PyList_New(0) returns NULL, PyArena_New() passes that on
Chris@87 31 XXX and an exception is set; OTOH, if the internal
Chris@87 32 XXX block_new(DEFAULT_BLOCK_SIZE) returns NULL, that's passed on but
Chris@87 33 XXX an exception is not set in that case).
Chris@87 34 */
Chris@87 35 PyAPI_FUNC(PyArena *) PyArena_New(void);
Chris@87 36 PyAPI_FUNC(void) PyArena_Free(PyArena *);
Chris@87 37
Chris@87 38 /* Mostly like malloc(), return the address of a block of memory spanning
Chris@87 39 * `size` bytes, or return NULL (without setting an exception) if enough
Chris@87 40 * new memory can't be obtained. Unlike malloc(0), PyArena_Malloc() with
Chris@87 41 * size=0 does not guarantee to return a unique pointer (the pointer
Chris@87 42 * returned may equal one or more other pointers obtained from
Chris@87 43 * PyArena_Malloc()).
Chris@87 44 * Note that pointers obtained via PyArena_Malloc() must never be passed to
Chris@87 45 * the system free() or realloc(), or to any of Python's similar memory-
Chris@87 46 * management functions. PyArena_Malloc()-obtained pointers remain valid
Chris@87 47 * until PyArena_Free(ar) is called, at which point all pointers obtained
Chris@87 48 * from the arena `ar` become invalid simultaneously.
Chris@87 49 */
Chris@87 50 PyAPI_FUNC(void *) PyArena_Malloc(PyArena *, size_t size);
Chris@87 51
Chris@87 52 /* This routine isn't a proper arena allocation routine. It takes
Chris@87 53 * a PyObject* and records it so that it can be DECREFed when the
Chris@87 54 * arena is freed.
Chris@87 55 */
Chris@87 56 PyAPI_FUNC(int) PyArena_AddPyObject(PyArena *, PyObject *);
Chris@87 57
Chris@87 58 #ifdef __cplusplus
Chris@87 59 }
Chris@87 60 #endif
Chris@87 61
Chris@87 62 #endif /* !Py_PYARENA_H */