blob: 4c75b558399cef6ea2ba504b577dad491362e3c3 [file] [log] [blame]
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001/* An arena-like memory interface for the compiler.
2 */
3
4#ifndef Py_PYARENA_H
5#define Py_PYARENA_H
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11 typedef struct _arena PyArena;
12
13 /* PyArena_New() and PyArena_Free() create a new arena and free it,
14 respectively. Once an arena has been created, it can be used
15 to allocate memory. Once it is freed, all the memory it allocated
16 is freed and none of its pointers are valid.
17
18 PyArena_New() returns an arena pointer. On error, it
19 returns a negative number and sets an exception.
20 */
21 PyAPI_FUNC(PyArena *) PyArena_New(void);
22 PyAPI_FUNC(void) PyArena_Free(PyArena *);
23
24 PyAPI_FUNC(void *) PyArena_Malloc(PyArena *, size_t);
25
Jeremy Hylton77f1bb22006-02-28 17:53:04 +000026 /* This routines isn't a proper arena allocation routine. It takes
27 a PyObject* and records it so that it can be DECREFed when the
28 arena is freed.
29 */
Neal Norwitzadb69fc2005-12-17 20:54:49 +000030 PyAPI_FUNC(int) PyArena_AddPyObject(PyArena *, PyObject *);
31
32#ifdef __cplusplus
33}
34#endif
35
36#endif /* !Py_PYARENA_H */