You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+51Lines changed: 51 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,57 @@ therefore no GPL restrictions apply.
17
17
* Not thread safe. API calls must be protected by a mutex in a multi-threaded environment.
18
18
* Works in environments with only minimal libc, uses only `stddef.h`, `stdbool.h`, `stdint.h` and `string.h`.
19
19
20
+
## How it works
21
+
22
+
This package offers constant, O(1)-time memory block allocation and deallocation.
23
+
24
+
The structure consists of an array indexed by `log(2, request_size)`.
25
+
In other words, requests are divided up according to the requsted size's most significant bit (MSB).
26
+
A pointer to the second level of the structure is contained in each item of the array.
27
+
At this level, the free blocks of each slab size are divided into x additional groups,
28
+
where x is a configurable number.
29
+
An array of size x that implements this partitioning is indexed by taking the value of the `log(2, x)` bits that follow the MSB.
30
+
Each value denotes the start of a linked list of free blocks (or is `NULL`).
31
+
32
+
Finding a free block in the correctly sized class (or, if none are available, in a larger size class) in constant time requires using the bitmaps representing the availability of free blocks (of a certain size class).
33
+
34
+
When `tlsf_free()` is called, the block examines if it may coalesce with nearby free blocks before returning to the free list.
0 commit comments