initial check-in, version 0.5.0
[musl] / src / malloc / DESIGN
1
2
3 In principle, this memory allocator is roughly equivalent to Doug
4 Lea's dlmalloc with fine-grained locking.
5
6
7
8 malloc:
9
10 Uses a freelist binned by chunk size, with a bitmap to optimize
11 searching for the smallest non-empty bin which can satisfy an
12 allocation. If no free chunks are available, it creates a new chunk of
13 the requested size and attempts to merge it with any existing free
14 chunk immediately below the newly created chunk.
15
16 Whether the chunk was obtained from a bin or newly created, it's
17 likely to be larger than the requested allocation. malloc always
18 finishes its work by passing the new chunk to realloc, which will
19 split it into two chunks and free the tail portion.
20
21
22