From cf7cd8be60c254b44b444c97dcb238d7cf3afd4c Mon Sep 17 00:00:00 2001 From: Brett Weiland Date: Tue, 21 Sep 2021 10:50:33 -0500 Subject: palloc smp safe (testing required, NOT pfree) --- src/kernel/heap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/kernel/heap.c') diff --git a/src/kernel/heap.c b/src/kernel/heap.c index db6392f..e2dcbc7 100644 --- a/src/kernel/heap.c +++ b/src/kernel/heap.c @@ -26,10 +26,11 @@ typedef struct __attribute__((packed)) heap_chunk { - unsigned int free:1; unsigned int size:4; //will use with flags later if needed unsigned int lsize:4; - unsigned long reserved:55; + unsigned int free:1; + unsigned int mutex:1; + unsigned long reserved:54; struct heap_chunk *fd; struct heap_chunk *bk; } chunk; @@ -203,6 +204,7 @@ void *malloc(size_t size) { return (void *)on_chunk + sizeof(chunk); } + void *realloc(void *old_chunk, size_t size) { void *new_chunk = malloc(size); memcpy(new_chunk, old_chunk, CHUNK_SIZE_FROM_INDEX(((chunk *)(old_chunk-24))->size)); -- cgit v1.2.3