From 72320021f73568672d27ac090b1c0594c6fa0296 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 19 Aug 2006 22:34:27 +0000 Subject: * malloc/malloc.c (_int_malloc): Limit number of unsorted blocks to sort in each call. --- malloc/malloc.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'malloc') diff --git a/malloc/malloc.c b/malloc/malloc.c index 890d3669e2..3f4ddcd7f7 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -4055,6 +4055,8 @@ _int_malloc(mstate av, size_t bytes) for(;;) { + int iters = 0; + bool any_larger = false; while ( (victim = unsorted_chunks(av)->bk) != unsorted_chunks(av)) { bck = victim->bk; if (__builtin_expect (victim->size <= 2 * SIZE_SZ, 0) @@ -4145,6 +4147,12 @@ _int_malloc(mstate av, size_t bytes) } } + if (size >= nb) + any_larger = true; +#define MAX_ITERS 10000 + if (++iters == MAX_ITERS) + break; + mark_bin(av, victim_index); victim->bk = bck; victim->fd = fwd; -- cgit v1.2.3