Skip to content

Commit e7fb985

Browse files
committed
gh-90815: Fix _PyMem_MimallocEnabled() compiler warning
Don't declare _PyMem_MimallocEnabled() if WITH_PYMALLOC macro is not defined (./configure --without-pymalloc). Fix also a typo in _PyInterpreterState_FinalizeAllocatedBlocks().
1 parent cd6e0a0 commit e7fb985

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

Objects/obmalloc.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -561,14 +561,13 @@ _PyMem_GetCurrentAllocatorName(void)
561561
}
562562

563563

564-
#if defined(WITH_PYMALLOC) || defined(WITH_MIMALLOC)
564+
#ifdef WITH_PYMALLOC
565565
static int
566566
_PyMem_DebugEnabled(void)
567567
{
568568
return (_PyObject.malloc == _PyMem_DebugMalloc);
569569
}
570570

571-
#ifdef WITH_PYMALLOC
572571
static int
573572
_PyMem_PymallocEnabled(void)
574573
{
@@ -579,7 +578,7 @@ _PyMem_PymallocEnabled(void)
579578
return (_PyObject.malloc == _PyObject_Malloc);
580579
}
581580
}
582-
#endif
581+
583582
#ifdef WITH_MIMALLOC
584583
static int
585584
_PyMem_MimallocEnabled(void)
@@ -591,8 +590,8 @@ _PyMem_MimallocEnabled(void)
591590
return (_PyObject.malloc == _PyObject_MiMalloc);
592591
}
593592
}
594-
#endif
595-
#endif // defined(WITH_PYMALLOC) || defined(WITH_MIMALLOC)
593+
#endif // WITH_MIMALLOC
594+
#endif // WITH_PYMALLOC
596595

597596

598597
static void
@@ -1028,7 +1027,6 @@ static bool count_blocks(
10281027
Py_ssize_t
10291028
_PyInterpreterState_GetAllocatedBlocks(PyInterpreterState *interp)
10301029
{
1031-
#ifdef WITH_MIMALLOC
10321030
// TODO(sgross): this only counts the current thread's blocks.
10331031
if (_PyMem_MimallocEnabled()) {
10341032
size_t allocated_blocks = 0;
@@ -1038,7 +1036,6 @@ _PyInterpreterState_GetAllocatedBlocks(PyInterpreterState *interp)
10381036

10391037
return allocated_blocks;
10401038
}
1041-
#endif
10421039

10431040
#ifdef Py_DEBUG
10441041
assert(has_own_state(interp));
@@ -1073,7 +1070,7 @@ _PyInterpreterState_GetAllocatedBlocks(PyInterpreterState *interp)
10731070
void
10741071
_PyInterpreterState_FinalizeAllocatedBlocks(PyInterpreterState *interp)
10751072
{
1076-
#ifdef WITH_MIAMLLOC
1073+
#ifdef WITH_MIMALLOC
10771074
if (_PyMem_MimallocEnabled()) {
10781075
return;
10791076
}

0 commit comments

Comments
 (0)