function,PyMem_Calloc,3.7,,
function,PyMem_Free,3.2,,
function,PyMem_Malloc,3.2,,
+function,PyMem_RawCalloc,3.13,,
+function,PyMem_RawFree,3.13,,
+function,PyMem_RawMalloc,3.13,,
+function,PyMem_RawRealloc,3.13,,
function,PyMem_Realloc,3.2,,
type,PyMemberDef,3.2,,full-abi
var,PyMemberDescr_Type,3.2,,
parameter names.
(Contributed by Serhiy Storchaka in :gh:`110815`.)
+* Add :c:func:`PyMem_RawMalloc`, :c:func:`PyMem_RawCalloc`,
+ :c:func:`PyMem_RawRealloc` and :c:func:`PyMem_RawFree` to the limited C API
+ (version 3.13).
+ (Contributed by Victor Stinner in :gh:`85283`.)
+
Porting to Python 3.13
----------------------
# error "this header file must not be included directly"
#endif
-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);
-
-
typedef enum {
/* PyMem_RawMalloc(), PyMem_RawRealloc() and PyMem_RawFree() */
PYMEM_DOMAIN_RAW,
#define PyMem_DEL(p) PyMem_Free((p))
+#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000
+// Memory allocator which doesn't require the GIL to be held.
+// Usually, it's just a thin wrapper to functions of the standard C library:
+// malloc(), calloc(), realloc() and free(). The difference is that
+// tracemalloc can track these memory allocations.
+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);
+#endif
+
#ifndef Py_LIMITED_API
# define Py_CPYTHON_PYMEM_H
# include "cpython/pymem.h"
"PyMem_Calloc",
"PyMem_Free",
"PyMem_Malloc",
+ "PyMem_RawCalloc",
+ "PyMem_RawFree",
+ "PyMem_RawMalloc",
+ "PyMem_RawRealloc",
"PyMem_Realloc",
"PyMemberDescr_Type",
"PyMember_GetOne",
--- /dev/null
+Add :c:func:`PyMem_RawMalloc`, :c:func:`PyMem_RawCalloc`,
+:c:func:`PyMem_RawRealloc` and :c:func:`PyMem_RawFree` to the limited C API.
+Patch by Victor Stinner.
added = '3.13'
[function.PyUnicode_EqualToUTF8AndSize]
added = '3.13'
+[function.PyMem_RawMalloc]
+ added = '3.13'
+[function.PyMem_RawCalloc]
+ added = '3.13'
+[function.PyMem_RawRealloc]
+ added = '3.13'
+[function.PyMem_RawFree]
+ added = '3.13'
EXPORT_FUNC(PyMem_Calloc)
EXPORT_FUNC(PyMem_Free)
EXPORT_FUNC(PyMem_Malloc)
+EXPORT_FUNC(PyMem_RawCalloc)
+EXPORT_FUNC(PyMem_RawFree)
+EXPORT_FUNC(PyMem_RawMalloc)
+EXPORT_FUNC(PyMem_RawRealloc)
EXPORT_FUNC(PyMem_Realloc)
EXPORT_FUNC(PyMember_GetOne)
EXPORT_FUNC(PyMember_SetOne)