summaryrefslogtreecommitdiffstats
path: root/README.txt
diff options
context:
space:
mode:
Diffstat (limited to 'README.txt')
-rw-r--r--README.txt49
1 files changed, 49 insertions, 0 deletions
diff --git a/README.txt b/README.txt
new file mode 100644
index 0000000..f613882
--- /dev/null
+++ b/README.txt
@@ -0,0 +1,49 @@
+diheap
+Drop In Heap
+
+A simple thread-unsafe linked list heap without weird metadata between
+allocations.
+
+Licensed under MIT
+
+Requirements:
+stdint.h
+ uintmax_t, uintptr_t
+stddef.h
+ NULL, size_t
+string.h
+ memset
+
+Example:
+########################
+#include "heap.h"
+
+#define HEAP_SIZE 0x10000
+
+struct heap stdlib_heap;
+struct mutex stdlib_heap_mutex;
+
+void*
+malloc(size_t size)
+{
+ void *r = 0;
+ mutex_lock(&stdlib_heap_mutex);
+ r = heap_alloc(&stdlib_heap, size);
+ mutex_unlock(&stdlib_heap_mutex);
+ return r;
+}
+
+void
+free(void *ptr)
+{
+ mutex_lock(&stdlib_heap_mutex);
+ heap_free(&stdlib_heap, size);
+ mutex_unlock(&stdlib_heap_mutex);
+}
+
+void
+__stdlib_init(void)
+{
+ heap_init(&stdlib_heap, (uintptr_t)sbrk(0), HEAP_SIZE);
+ //Heap is done baybee!
+}