gh-90815: Fix _PyMem_MimallocEnabled() compiler warning (#111522)

Don't declare _PyMem_MimallocEnabled() if WITH_PYMALLOC macro is not
defined (./configure --without-pymalloc).

Fix also a typo in _PyInterpreterState_FinalizeAllocatedBlocks().
This commit is contained in:
Victor Stinner 2023-10-30 23:05:49 +01:00 committed by GitHub
parent 804a207c16
commit da4d3142a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 6 deletions

View File

@ -561,14 +561,13 @@ _PyMem_GetCurrentAllocatorName(void)
} }
#if defined(WITH_PYMALLOC) || defined(WITH_MIMALLOC) #ifdef WITH_PYMALLOC
static int static int
_PyMem_DebugEnabled(void) _PyMem_DebugEnabled(void)
{ {
return (_PyObject.malloc == _PyMem_DebugMalloc); return (_PyObject.malloc == _PyMem_DebugMalloc);
} }
#ifdef WITH_PYMALLOC
static int static int
_PyMem_PymallocEnabled(void) _PyMem_PymallocEnabled(void)
{ {
@ -579,7 +578,7 @@ _PyMem_PymallocEnabled(void)
return (_PyObject.malloc == _PyObject_Malloc); return (_PyObject.malloc == _PyObject_Malloc);
} }
} }
#endif
#ifdef WITH_MIMALLOC #ifdef WITH_MIMALLOC
static int static int
_PyMem_MimallocEnabled(void) _PyMem_MimallocEnabled(void)
@ -591,8 +590,9 @@ _PyMem_MimallocEnabled(void)
return (_PyObject.malloc == _PyObject_MiMalloc); return (_PyObject.malloc == _PyObject_MiMalloc);
} }
} }
#endif #endif // WITH_MIMALLOC
#endif // defined(WITH_PYMALLOC) || defined(WITH_MIMALLOC)
#endif // WITH_PYMALLOC
static void static void
@ -1073,7 +1073,7 @@ _PyInterpreterState_GetAllocatedBlocks(PyInterpreterState *interp)
void void
_PyInterpreterState_FinalizeAllocatedBlocks(PyInterpreterState *interp) _PyInterpreterState_FinalizeAllocatedBlocks(PyInterpreterState *interp)
{ {
#ifdef WITH_MIAMLLOC #ifdef WITH_MIMALLOC
if (_PyMem_MimallocEnabled()) { if (_PyMem_MimallocEnabled()) {
return; return;
} }