Skip to content

Commit

Permalink
* malloc/malloc.c (_int_malloc): Limit number of unsorted blocks
Browse files Browse the repository at this point in the history
	to sort in each call.
  • Loading branch information
Ulrich Drepper committed Aug 19, 2006
1 parent ed3691b commit 7232002
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
2006-08-19 Ulrich Drepper <drepper@redhat.com>

* malloc/malloc.c (_int_malloc): Limit number of unsorted blocks
to sort in each call.

* nis/nss_nis/nis-service.c (internal_nis_getservent_r): . If map
is empty simply return and use next service.
* nis/nss_nis/nis-rpc.c (internal_nis_getrpcent_r): Likewise.
Expand Down
8 changes: 8 additions & 0 deletions malloc/malloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 7232002

Please sign in to comment.