summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--research/heap.txt42
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