summaryrefslogtreecommitdiff
path: root/src/kernel/malloc.h
diff options
context:
space:
mode:
authordzwdz2024-07-16 23:55:32 +0200
committerdzwdz2024-07-17 00:01:15 +0200
commit473112b1541cf81fa3670e0d1cb6de1c4a3281de (patch)
tree4df8f777e2150468e8866f4496e1de32b309ccda /src/kernel/malloc.h
parente29f0e294ac841e2036fe514df4ed66f5d0ec46f (diff)
kernel: make kmalloc accept a numeric "tag" instead of a freeform description
This will both let me save space in the allocation header, and make the debugprint more readable.
Diffstat (limited to 'src/kernel/malloc.h')
-rw-r--r--src/kernel/malloc.h28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/kernel/malloc.h b/src/kernel/malloc.h
index bda2745..a38d49b 100644
--- a/src/kernel/malloc.h
+++ b/src/kernel/malloc.h
@@ -10,6 +10,28 @@
* dead code. */
#define KMALLOC_MAX 1024
+/* also see the string table in malloc.c */
+enum MallocTag {
+ TagInvalid,
+ TagKernelFs,
+ TagProcFs,
+ TagUserFs,
+ TagOpenPath,
+ TagMountPath,
+ TagMountUser,
+ TagMountRoot,
+ TagExecbuf,
+ TagVfsReq,
+ TagHandleset,
+ TagHandle,
+ TagProcess,
+ TagProcessHandle,
+ TagDevTime,
+ TagRootCache,
+ TagPageRefcount,
+ TagLast,
+};
+
void mem_init(void *memtop);
void mem_reserve(void *addr, size_t len);
void mem_debugprint(void);
@@ -24,12 +46,12 @@ void *page_zalloc(size_t pages);
// frees `pages` consecutive pages starting from *first
void page_free(void *first, size_t pages);
-void *kmalloc(size_t len, const char *desc);
+void *kmalloc(size_t len, enum MallocTag tag);
void kfree(void *ptr);
// TODO calloc
-static inline void *kzalloc(size_t len, const char *desc) {
- void *b = kmalloc(len, desc);
+static inline void *kzalloc(size_t len, enum MallocTag tag) {
+ void *b = kmalloc(len, tag);
memset(b, 0, len);
return b;
}