@@ -737,7 +737,8 @@ get_free_list (void)
/* Lock and return an arena that can be reused for memory allocation.
Avoid AVOID_ARENA as we have already failed to allocate memory in
- it and it is currently locked. */
+ it and it is currently locked. Note that AVOID_ARENA is either
+ NULL or the main_arena given the logic in arena_get_retry. */
static mstate
reused_arena (mstate avoid_arena)
{
@@ -752,6 +753,11 @@ reused_arena (mstate avoid_arena)
result = next_to_use;
do
{
+ /* This does not take into account avoid_arena. We don't care about
+ that case and it would complicate the logic. AVOID_ARENA is either
+ NULL or &main_arena, in the case of the latter (the only case
+ where this matters) we might return back &main_arena after just
+ having failed there, retry, and fall back to sysmalloc. */
if (!arena_is_corrupt (result) && !mutex_trylock (&result->mutex))
goto out;
@@ -800,6 +806,11 @@ out:
return result;
}
+/* Get an arena from the free list, or a new one if one isn't free,
+ or lastly try to reuse an existing arena. Note that AVOID_ARENA
+ is either NULL or the main_arena because of the logic in
+ arena_get_retry which is the only place where arena_get2 is called
+ with a non-NULL avoid_arena. */
static mstate
internal_function
arena_get2 (size_t size, mstate avoid_arena)