From 80a190674606aad3d7184f2887ea3ca1d9c89636 Mon Sep 17 00:00:00 2001 From: Thomas Kluyver <thomas@kluyver.me.uk> Date: Mon, 10 Feb 2025 08:27:57 +0000 Subject: [PATCH] Switch back to PyMem_Raw functions for zlib to allocate & free memory --- src/zlib_into.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/zlib_into.c b/src/zlib_into.c index fcdc294..d07fd8c 100644 --- a/src/zlib_into.c +++ b/src/zlib_into.c @@ -20,17 +20,13 @@ PyZlib_Malloc(voidpf ctx, uInt items, uInt size) return NULL; /* PyMem_Malloc() cannot be used: the GIL is not held when inflate() and deflate() are called */ - /* The builtin zlib module uses PyMem_RawMalloc here, but this was only - added to the stable ABI from Python 3.13, so use plain malloc for now */ - return malloc((size_t)items * (size_t)size); + return PyMem_RawMalloc((size_t)items * (size_t)size); } static void PyZlib_Free(voidpf ctx, void *ptr) { - /* The builtin zlib module uses PyMem_RawFree here, but this was only - added to the stable ABI from Python 3.13, so use plain free for now */ - free(ptr); + PyMem_RawFree(ptr); } // zlib_error copied from CPython -- GitLab