(root)/
Python-3.12.0/
Include/
internal/
pycore_pymem_init.h
       1  #ifndef Py_INTERNAL_PYMEM_INIT_H
       2  #define Py_INTERNAL_PYMEM_INIT_H
       3  #ifdef __cplusplus
       4  extern "C" {
       5  #endif
       6  
       7  #ifndef Py_BUILD_CORE
       8  #  error "this header requires Py_BUILD_CORE define"
       9  #endif
      10  
      11  #include "pycore_pymem.h"
      12  
      13  
      14  /********************************/
      15  /* the allocators' initializers */
      16  
      17  extern void * _PyMem_RawMalloc(void *, size_t);
      18  extern void * _PyMem_RawCalloc(void *, size_t, size_t);
      19  extern void * _PyMem_RawRealloc(void *, void *, size_t);
      20  extern void _PyMem_RawFree(void *, void *);
      21  #define PYRAW_ALLOC {NULL, _PyMem_RawMalloc, _PyMem_RawCalloc, _PyMem_RawRealloc, _PyMem_RawFree}
      22  
      23  #ifdef WITH_PYMALLOC
      24  extern void* _PyObject_Malloc(void *, size_t);
      25  extern void* _PyObject_Calloc(void *, size_t, size_t);
      26  extern void _PyObject_Free(void *, void *);
      27  extern void* _PyObject_Realloc(void *, void *, size_t);
      28  #  define PYOBJ_ALLOC {NULL, _PyObject_Malloc, _PyObject_Calloc, _PyObject_Realloc, _PyObject_Free}
      29  #else
      30  # define PYOBJ_ALLOC PYRAW_ALLOC
      31  #endif  // WITH_PYMALLOC
      32  
      33  #define PYMEM_ALLOC PYOBJ_ALLOC
      34  
      35  extern void* _PyMem_DebugRawMalloc(void *, size_t);
      36  extern void* _PyMem_DebugRawCalloc(void *, size_t, size_t);
      37  extern void* _PyMem_DebugRawRealloc(void *, void *, size_t);
      38  extern void _PyMem_DebugRawFree(void *, void *);
      39  
      40  extern void* _PyMem_DebugMalloc(void *, size_t);
      41  extern void* _PyMem_DebugCalloc(void *, size_t, size_t);
      42  extern void* _PyMem_DebugRealloc(void *, void *, size_t);
      43  extern void _PyMem_DebugFree(void *, void *);
      44  
      45  #define PYDBGRAW_ALLOC(runtime) \
      46      {&(runtime).allocators.debug.raw, _PyMem_DebugRawMalloc, _PyMem_DebugRawCalloc, _PyMem_DebugRawRealloc, _PyMem_DebugRawFree}
      47  #define PYDBGMEM_ALLOC(runtime) \
      48      {&(runtime).allocators.debug.mem, _PyMem_DebugMalloc, _PyMem_DebugCalloc, _PyMem_DebugRealloc, _PyMem_DebugFree}
      49  #define PYDBGOBJ_ALLOC(runtime) \
      50      {&(runtime).allocators.debug.obj, _PyMem_DebugMalloc, _PyMem_DebugCalloc, _PyMem_DebugRealloc, _PyMem_DebugFree}
      51  
      52  extern void * _PyMem_ArenaAlloc(void *, size_t);
      53  extern void _PyMem_ArenaFree(void *, void *, size_t);
      54  
      55  #ifdef Py_DEBUG
      56  # define _pymem_allocators_standard_INIT(runtime) \
      57      { \
      58          PYDBGRAW_ALLOC(runtime), \
      59          PYDBGMEM_ALLOC(runtime), \
      60          PYDBGOBJ_ALLOC(runtime), \
      61      }
      62  #else
      63  # define _pymem_allocators_standard_INIT(runtime) \
      64      { \
      65          PYRAW_ALLOC, \
      66          PYMEM_ALLOC, \
      67          PYOBJ_ALLOC, \
      68      }
      69  #endif
      70  
      71  #define _pymem_allocators_debug_INIT \
      72     { \
      73         {'r', PYRAW_ALLOC}, \
      74         {'m', PYMEM_ALLOC}, \
      75         {'o', PYOBJ_ALLOC}, \
      76     }
      77  
      78  #  define _pymem_allocators_obj_arena_INIT \
      79      { NULL, _PyMem_ArenaAlloc, _PyMem_ArenaFree }
      80  
      81  
      82  #ifdef __cplusplus
      83  }
      84  #endif
      85  #endif  // !Py_INTERNAL_PYMEM_INIT_H