Neal Norwitz | adb69fc | 2005-12-17 20:54:49 +0000 | [diff] [blame] | 1 | /* An arena-like memory interface for the compiler. |
| 2 | */ |
| 3 | |
| 4 | #ifndef Py_PYARENA_H |
| 5 | #define Py_PYARENA_H |
| 6 | |
| 7 | #ifdef __cplusplus |
| 8 | extern "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 Hylton | 77f1bb2 | 2006-02-28 17:53:04 +0000 | [diff] [blame] | 26 | /* 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 Norwitz | adb69fc | 2005-12-17 20:54:49 +0000 | [diff] [blame] | 30 | PyAPI_FUNC(int) PyArena_AddPyObject(PyArena *, PyObject *); |
| 31 | |
| 32 | #ifdef __cplusplus |
| 33 | } |
| 34 | #endif |
| 35 | |
| 36 | #endif /* !Py_PYARENA_H */ |