aboutsummaryrefslogtreecommitdiff
path: root/libc/inc
diff options
context:
space:
mode:
authorMarvin Borner2020-08-26 18:01:03 +0200
committerMarvin Borner2020-08-26 18:01:03 +0200
commit3f1668290da19734dcbfed633b6f415d1fa21a1a (patch)
tree85fa32e14c0db07f98b872f6ba9bf9ac6b4de9ca /libc/inc
parentae31470ce5d666981ab1fe50cb2b4b38ca4b113f (diff)
Started stack allocator.
This will replace the current linear allocator so we can free and realloc memory correctly. This is especially important for the window resizing due to a fixed LFB size.
Diffstat (limited to 'libc/inc')
-rw-r--r--libc/inc/mem.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/libc/inc/mem.h b/libc/inc/mem.h
index cb64ce8..9aeeee9 100644
--- a/libc/inc/mem.h
+++ b/libc/inc/mem.h
@@ -7,8 +7,13 @@
// Huh
#ifdef kernel
-#define malloc(n) (void *)((HEAP += n) - n) // TODO: Implement real/better malloc/free
-#define free(ptr)
+#define HEAP_SIZE 0x10000
+#define HEAP_MAGIC 0x42
+void heap_init(u32 start);
+void *malloc(u32 size);
+void free(void *ptr);
+/* #define malloc(n) (void *)((HEAP += n) - n) // TODO: Implement real/better malloc/free */
+/* #define free(ptr) */
#elif defined(userspace)
#include <sys.h>
#define malloc(n) (void *)sys1(SYS_MALLOC, n)
@@ -17,11 +22,8 @@
#error "No lib target specified. Please use -Dkernel or -Duserspace"
#endif
-u32 HEAP;
-u32 HEAP_START;
-
void *memcpy(void *dest, const void *src, u32 n);
-void *memset(void *dest, int c, u32 n);
+void *memset(void *dest, int val, u32 n);
int memcmp(const void *s1, const void *s2, u32 n);
#endif