/* An arena-like memory interface for the compiler.*/#ifndef Py_LIMITED_API#ifndef Py_PYARENA_H#define Py_PYARENA_H#ifdef __cplusplusextern "C" {#endiftypedef struct _arena PyArena;/* PyArena_New() and PyArena_Free() create a new arena and free it,respectively. Once an arena has been created, it can be usedto allocate memory via PyArena_Malloc(). Pointers to PyObject canalso be registered with the arena via PyArena_AddPyObject(), and thearena will ensure that the PyObjects stay alive at least untilPyArena_Free() is called. When an arena is freed, all the memory itallocated is freed, the arena releases internal references to registeredPyObject*, and none of its pointers are valid.XXX (tim) What does "none of its pointers are valid" mean? Does itXXX mean that pointers previously obtained via PyArena_Malloc() areXXX no longer valid? (That's clearly true, but not sure that's whatXXX the text is trying to say.)PyArena_New() returns an arena pointer. On error, itreturns a negative number and sets an exception.XXX (tim): Not true. On error, PyArena_New() actually returns NULL,XXX and looks like it may or may not set an exception (e.g., if theXXX internal PyList_New(0) returns NULL, PyArena_New() passes that onXXX and an exception is set; OTOH, if the internalXXX block_new(DEFAULT_BLOCK_SIZE) returns NULL, that's passed on butXXX an exception is not set in that case).*/PyAPI_FUNC(PyArena *) PyArena_New(void);PyAPI_FUNC(void) PyArena_Free(PyArena *);/* 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 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 *);#ifdef __cplusplus}#endif#endif /* !Py_PYARENA_H */#endif /* Py_LIMITED_API */
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。