extern void _PyMem_MiFree(void *, void *);
extern void* _PyMem_MiRealloc(void *, void *, size_t);
# define PYMEM_ALLOC {NULL, _PyMem_MiMalloc, _PyMem_MiCalloc, _PyMem_MiRealloc, _PyMem_MiFree}
+extern void* _PyMem_MiRawMalloc(void *, size_t);
+extern void* _PyMem_MiRawCalloc(void *, size_t, size_t);
+extern void _PyMem_MiRawFree(void *, void *);
+extern void* _PyMem_MiRawRealloc(void *, void *, size_t);
+# undef PYRAW_ALLOC
+# define PYRAW_ALLOC {NULL, _PyMem_MiRawMalloc, _PyMem_MiRawCalloc, _PyMem_MiRawRealloc, _PyMem_MiRawFree}
#elif defined(WITH_PYMALLOC)
extern void* _PyObject_Malloc(void *, size_t);
extern void* _PyObject_Calloc(void *, size_t, size_t);
mi_free(ptr);
}
+void *
+_PyMem_MiRawMalloc(void *ctx, size_t size)
+{
+ return mi_malloc(size);
+}
+
+void *
+_PyMem_MiRawCalloc(void *ctx, size_t nelem, size_t elsize)
+{
+ return mi_calloc(nelem, elsize);
+}
+
+void *
+_PyMem_MiRawRealloc(void *ctx, void *ptr, size_t size)
+{
+ return mi_realloc(ptr, size);
+}
+
+void
+_PyMem_MiRawFree(void *ctx, void *ptr)
+{
+ mi_free(ptr);
+}
#endif // WITH_MIMALLOC
#ifdef WITH_MIMALLOC
-# define MIMALLOC_ALLOC {NULL, _PyMem_MiMalloc, _PyMem_MiCalloc, _PyMem_MiRealloc, _PyMem_MiFree}
+# define MIMALLOC_ALLOC {NULL, _PyMem_MiMalloc, _PyMem_MiCalloc, _PyMem_MiRealloc, _PyMem_MiFree}
+# define MIMALLOC_RAWALLOC {NULL, _PyMem_MiRawMalloc, _PyMem_MiRawCalloc, _PyMem_MiRawRealloc, _PyMem_MiRawFree}
# define MIMALLOC_OBJALLOC {NULL, _PyObject_MiMalloc, _PyObject_MiCalloc, _PyObject_MiRealloc, _PyObject_MiFree}
#endif
#if defined(Py_GIL_DISABLED)
// Py_GIL_DISABLED requires using mimalloc for "mem" and "obj" domains.
-# define PYRAW_ALLOC MALLOC_ALLOC
+# define PYRAW_ALLOC MIMALLOC_RAWALLOC
# define PYMEM_ALLOC MIMALLOC_ALLOC
# define PYOBJ_ALLOC MIMALLOC_OBJALLOC
#elif defined(WITH_PYMALLOC)
case PYMEM_ALLOCATOR_MIMALLOC:
case PYMEM_ALLOCATOR_MIMALLOC_DEBUG:
{
- PyMemAllocatorEx malloc_alloc = MALLOC_ALLOC;
+ PyMemAllocatorEx malloc_alloc = MIMALLOC_RAWALLOC;
set_allocator_unlocked(PYMEM_DOMAIN_RAW, &malloc_alloc);
PyMemAllocatorEx pymalloc = MIMALLOC_ALLOC;
#ifdef WITH_MIMALLOC
PyMemAllocatorEx mimalloc = MIMALLOC_ALLOC;
PyMemAllocatorEx mimalloc_obj = MIMALLOC_OBJALLOC;
+ PyMemAllocatorEx mimalloc_raw = MIMALLOC_RAWALLOC;
#endif
if (pymemallocator_eq(&_PyMem_Raw, &malloc_alloc) &&
}
#endif
#ifdef WITH_MIMALLOC
- if (pymemallocator_eq(&_PyMem_Raw, &malloc_alloc) &&
+ if (pymemallocator_eq(&_PyMem_Raw, &mimalloc_raw) &&
pymemallocator_eq(&_PyMem, &mimalloc) &&
pymemallocator_eq(&_PyObject, &mimalloc_obj))
{
}
#endif
#ifdef WITH_MIMALLOC
- if (pymemallocator_eq(&_PyMem_Debug.raw.alloc, &malloc_alloc) &&
+ if (pymemallocator_eq(&_PyMem_Debug.raw.alloc, &mimalloc_raw) &&
pymemallocator_eq(&_PyMem_Debug.mem.alloc, &mimalloc) &&
pymemallocator_eq(&_PyMem_Debug.obj.alloc, &mimalloc_obj))
{