Skip to content

Commit 4471ac7

Browse files
committed
Fix for various config options.
Make work for --without-pymalloc and for WITH_PYMALLOC_RADIX_TREE=0.
1 parent 0d0c5a9 commit 4471ac7

File tree

1 file changed

+34
-32
lines changed

1 file changed

+34
-32
lines changed

Objects/obmalloc.c

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2615,38 +2615,6 @@ _PyObject_DebugDumpAddress(const void *p)
26152615
_PyMem_DumpTraceback(fileno(stderr), p);
26162616
}
26172617

2618-
static void
2619-
free_arenas(PyInterpreterState *interp)
2620-
{
2621-
OMState *state = &interp->obmalloc;
2622-
for (uint i = 0; i < maxarenas; ++i) {
2623-
// free each obmalloc memory arena
2624-
struct arena_object *ao = &allarenas[i];
2625-
_PyObject_Arena.free(_PyObject_Arena.ctx,
2626-
(void *)ao->address, ARENA_SIZE);
2627-
}
2628-
// free the array containing pointers to all arenas
2629-
PyMem_RawFree(allarenas);
2630-
#if WITH_PYMALLOC_RADIX_TREE
2631-
// Free the middle and bottom nodes of the radix tree. These are allocated
2632-
// by arena_map_mark_used() but not freed when arenas are freed.
2633-
for (int i1 = 0; i1 < MAP_TOP_LENGTH; i1++) {
2634-
arena_map_mid_t *mid = arena_map_root.ptrs[i1];
2635-
if (mid == NULL) {
2636-
continue;
2637-
}
2638-
for (int i2 = 0; i2 < MAP_MID_LENGTH; i2++) {
2639-
arena_map_bot_t *bot = arena_map_root.ptrs[i1]->ptrs[i2];
2640-
if (bot == NULL) {
2641-
continue;
2642-
}
2643-
PyMem_RawFree(bot);
2644-
}
2645-
PyMem_RawFree(mid);
2646-
}
2647-
#endif
2648-
}
2649-
26502618
static size_t
26512619
printone(FILE *out, const char* msg, size_t value)
26522620
{
@@ -2700,6 +2668,40 @@ _PyDebugAllocatorStats(FILE *out,
27002668

27012669
#ifdef WITH_PYMALLOC
27022670

2671+
static void
2672+
free_arenas(PyInterpreterState *interp)
2673+
{
2674+
OMState *state = &interp->obmalloc;
2675+
for (uint i = 0; i < maxarenas; ++i) {
2676+
// free each obmalloc memory arena
2677+
struct arena_object *ao = &allarenas[i];
2678+
_PyObject_Arena.free(_PyObject_Arena.ctx,
2679+
(void *)ao->address, ARENA_SIZE);
2680+
}
2681+
// free the array containing pointers to all arenas
2682+
PyMem_RawFree(allarenas);
2683+
#if WITH_PYMALLOC_RADIX_TREE
2684+
#ifdef USE_INTERIOR_NODES
2685+
// Free the middle and bottom nodes of the radix tree. These are allocated
2686+
// by arena_map_mark_used() but not freed when arenas are freed.
2687+
for (int i1 = 0; i1 < MAP_TOP_LENGTH; i1++) {
2688+
arena_map_mid_t *mid = arena_map_root.ptrs[i1];
2689+
if (mid == NULL) {
2690+
continue;
2691+
}
2692+
for (int i2 = 0; i2 < MAP_MID_LENGTH; i2++) {
2693+
arena_map_bot_t *bot = arena_map_root.ptrs[i1]->ptrs[i2];
2694+
if (bot == NULL) {
2695+
continue;
2696+
}
2697+
PyMem_RawFree(bot);
2698+
}
2699+
PyMem_RawFree(mid);
2700+
}
2701+
#endif
2702+
#endif
2703+
}
2704+
27032705
#ifdef Py_DEBUG
27042706
/* Is target in the list? The list is traversed via the nextpool pointers.
27052707
* The list may be NULL-terminated, or circular. Return 1 if target is in

0 commit comments

Comments
 (0)