blob: 4ec78f18495c7f88c1e938baed92ad0f2fee9d3e (
plain)
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
|
Data Structures
===============
heap
top
free_head
free_tail
block
next_free
user_data
Functions
=========
malloc(heap)
if heap->top unset
heap->top = 0
return 0
elif heap->free_head unset
return ++heap->top
else
block = heap->free_head
if heap->free_head->next_free set
heap->free_head = heap->free_head->next_free
else
unset heap->free_head
unset heap->free_tail
return block
free(heap, ptr)
if heap->free_tail unset
heap->free_head = heap->free_tail = ptr
else
heap->free_tail->next_free = ptr
heap->free_tail = ptr
Return register:
__malloc_r
Or:
__mr
|