1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
| static void * _int_malloc (mstate av, size_t bytes) { if ((unsigned long) (nb) <= (unsigned long) (get_max_fast ())) ... if (in_smallbin_range (nb)) ... else ... for(;; ) { while ((victim = unsorted_chunks (av)->bk) != unsorted_chunks (av)) { if() ...
unsorted_chunks (av)->bk = bck; bck->fd = unsorted_chunks (av);
if (size == nb) return ; if (in_smallbin_range (size)) { ... } else { victim_index = largebin_index (size); bck = bin_at (av, victim_index); fwd = bck->fd;
if (fwd != bck) { size |= PREV_INUSE; assert ((bck->bk->size & NON_MAIN_ARENA) == 0); if ((unsigned long) (size) < (unsigned long) (bck->bk->size)) { fwd = bck; bck = bck->bk;
victim->fd_nextsize = fwd->fd; victim->bk_nextsize = fwd->fd->bk_nextsize; fwd->fd->bk_nextsize = victim->bk_nextsize->fd_nextsize = victim; } else { assert ((fwd->size & NON_MAIN_ARENA) == 0); while ((unsigned long) size < fwd->size) { fwd = fwd->fd_nextsize; assert ((fwd->size & NON_MAIN_ARENA) == 0); }
if ((unsigned long) size == (unsigned long) fwd->size) fwd = fwd->fd; else {
victim->fd_nextsize = fwd; victim->bk_nextsize = fwd->bk_nextsize; fwd->bk_nextsize = victim; victim->bk_nextsize->fd_nextsize = victim;
}
bck = fwd->bk;
} } else victim->fd_nextsize = victim->bk_nextsize = victim; } mark_bin (av, victim_index); victim->bk = bck; victim->fd = fwd; fwd->bk = victim;
bck->fd = victim;
#define MAX_ITERS 10000 if (++iters >= MAX_ITERS) break; }
} }
|