figured out how to make the block header smaller actually

This commit is contained in:
IoIxD 2026-01-22 11:51:33 -07:00
commit 9ebc058188

View file

@ -15,7 +15,6 @@ struct msh_linux_block_t {
msh_linux_block *prev; msh_linux_block *prev;
msh_linux_block *next; msh_linux_block *next;
unsigned char free; unsigned char free;
char data[1];
}; };
#define MSH_BLOCK_SIZE 21 #define MSH_BLOCK_SIZE 21
@ -50,7 +49,7 @@ static msh_linux_block *extend_heap(msh_linux_block *last, SIZE_TYPE size) {
static void split_block(msh_linux_block *b, SIZE_TYPE size) { static void split_block(msh_linux_block *b, SIZE_TYPE size) {
msh_linux_block *new; msh_linux_block *new;
new = (msh_linux_block *)b->data + size; new = ((msh_linux_block *)&b->free) + size + 1;
new->size = b->size - size - MSH_BLOCK_SIZE; new->size = b->size - size - MSH_BLOCK_SIZE;
new->next = b->next; new->next = b->next;
new->free = 1; new->free = 1;
@ -103,7 +102,7 @@ void *msh_allocate(SIZE_TYPE size) {
} }
msh_linux_base = b; msh_linux_base = b;
} }
return b->data; return (&b->free) + 1;
}; };
void msh_deallocate(void *ptr) { void msh_deallocate(void *ptr) {