diff options
author | P. J. McDermott <pj@pehjota.net> | 2017-02-09 23:59:51 (EST) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2017-02-10 00:14:38 (EST) |
commit | 9c656295474ab6628a48ca94ca5ae16ddf524a5b (patch) | |
tree | 8d657e7213883e99b91276ab4ff19c2c914293bb | |
parent | 80731ced09aab7e9191be8a33b5fb5b93b537c81 (diff) | |
download | eggshell-9c656295474ab6628a48ca94ca5ae16ddf524a5b.zip eggshell-9c656295474ab6628a48ca94ca5ae16ddf524a5b.tar.gz eggshell-9c656295474ab6628a48ca94ca5ae16ddf524a5b.tar.bz2 |
research/heap.txt: New file
-rw-r--r-- | research/heap.txt | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/research/heap.txt b/research/heap.txt new file mode 100644 index 0000000..4ec78f1 --- /dev/null +++ b/research/heap.txt @@ -0,0 +1,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 |