File indexing completed on 2025-03-13 09:20:55
0001 #ifndef Py_CPYTHON_PYMEM_H
0002 # error "this header file must not be included directly"
0003 #endif
0004
0005 PyAPI_FUNC(void *) PyMem_RawMalloc(size_t size);
0006 PyAPI_FUNC(void *) PyMem_RawCalloc(size_t nelem, size_t elsize);
0007 PyAPI_FUNC(void *) PyMem_RawRealloc(void *ptr, size_t new_size);
0008 PyAPI_FUNC(void) PyMem_RawFree(void *ptr);
0009
0010
0011 PyAPI_FUNC(const char*) _PyMem_GetCurrentAllocatorName(void);
0012
0013
0014 PyAPI_FUNC(char *) _PyMem_RawStrdup(const char *str);
0015
0016
0017 PyAPI_FUNC(char *) _PyMem_Strdup(const char *str);
0018
0019
0020 PyAPI_FUNC(wchar_t*) _PyMem_RawWcsdup(const wchar_t *str);
0021
0022
0023 typedef enum {
0024
0025 PYMEM_DOMAIN_RAW,
0026
0027
0028 PYMEM_DOMAIN_MEM,
0029
0030
0031 PYMEM_DOMAIN_OBJ
0032 } PyMemAllocatorDomain;
0033
0034 typedef enum {
0035 PYMEM_ALLOCATOR_NOT_SET = 0,
0036 PYMEM_ALLOCATOR_DEFAULT = 1,
0037 PYMEM_ALLOCATOR_DEBUG = 2,
0038 PYMEM_ALLOCATOR_MALLOC = 3,
0039 PYMEM_ALLOCATOR_MALLOC_DEBUG = 4,
0040 #ifdef WITH_PYMALLOC
0041 PYMEM_ALLOCATOR_PYMALLOC = 5,
0042 PYMEM_ALLOCATOR_PYMALLOC_DEBUG = 6,
0043 #endif
0044 } PyMemAllocatorName;
0045
0046
0047 typedef struct {
0048
0049 void *ctx;
0050
0051
0052 void* (*malloc) (void *ctx, size_t size);
0053
0054
0055 void* (*calloc) (void *ctx, size_t nelem, size_t elsize);
0056
0057
0058 void* (*realloc) (void *ctx, void *ptr, size_t new_size);
0059
0060
0061 void (*free) (void *ctx, void *ptr);
0062 } PyMemAllocatorEx;
0063
0064
0065 PyAPI_FUNC(void) PyMem_GetAllocator(PyMemAllocatorDomain domain,
0066 PyMemAllocatorEx *allocator);
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079 PyAPI_FUNC(void) PyMem_SetAllocator(PyMemAllocatorDomain domain,
0080 PyMemAllocatorEx *allocator);
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098 PyAPI_FUNC(void) PyMem_SetupDebugHooks(void);