summaryrefslogtreecommitdiff
path: root/Include/pymem.h
diff options
context:
space:
mode:
Diffstat (limited to 'Include/pymem.h')
-rw-r--r--Include/pymem.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/Include/pymem.h b/Include/pymem.h
index 043db64deb..431e5b6d0f 100644
--- a/Include/pymem.h
+++ b/Include/pymem.h
@@ -16,8 +16,51 @@ PyAPI_FUNC(void *) PyMem_RawMalloc(size_t size);
PyAPI_FUNC(void *) PyMem_RawCalloc(size_t nelem, size_t elsize);
PyAPI_FUNC(void *) PyMem_RawRealloc(void *ptr, size_t new_size);
PyAPI_FUNC(void) PyMem_RawFree(void *ptr);
+
+/* Configure the Python memory allocators. Pass NULL to use default
+ allocators. */
+PyAPI_FUNC(int) _PyMem_SetupAllocators(const char *opt);
+
+#ifdef WITH_PYMALLOC
+PyAPI_FUNC(int) _PyMem_PymallocEnabled(void);
#endif
+/* Identifier of an address space (domain) in tracemalloc */
+typedef unsigned int _PyTraceMalloc_domain_t;
+
+/* Track an allocated memory block in the tracemalloc module.
+ Return 0 on success, return -1 on error (failed to allocate memory to store
+ the trace).
+
+ Return -2 if tracemalloc is disabled.
+
+ If memory block is already tracked, update the existing trace. */
+PyAPI_FUNC(int) _PyTraceMalloc_Track(
+ _PyTraceMalloc_domain_t domain,
+ Py_uintptr_t ptr,
+ size_t size);
+
+/* Untrack an allocated memory block in the tracemalloc module.
+ Do nothing if the block was not tracked.
+
+ Return -2 if tracemalloc is disabled, otherwise return 0. */
+PyAPI_FUNC(int) _PyTraceMalloc_Untrack(
+ _PyTraceMalloc_domain_t domain,
+ Py_uintptr_t ptr);
+
+/* Get the traceback where a memory block was allocated.
+
+ Return a tuple of (filename: str, lineno: int) tuples.
+
+ Return None if the tracemalloc module is disabled or if the memory block
+ is not tracked by tracemalloc.
+
+ Raise an exception and return NULL on error. */
+PyAPI_FUNC(PyObject*) _PyTraceMalloc_GetTraceback(
+ _PyTraceMalloc_domain_t domain,
+ Py_uintptr_t ptr);
+#endif /* !Py_LIMITED_API */
+
/* BEWARE: