From 97bf06b2e80168cbafc2ed1888b5d998107142a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20O=2E=20Sel=C3=A5sdal?= Date: Sat, 5 Jul 2025 20:09:12 +0200 Subject: [PATCH] Refactor SAlloc --- src/salloc.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/salloc.c b/src/salloc.c index 5f3a976..8e2b17d 100644 --- a/src/salloc.c +++ b/src/salloc.c @@ -39,6 +39,8 @@ add_chunk(SAlloc *p, Chunk *c) if (c == NULL) return c; + p->current->next = c; + c->next = NULL; c->firstfree = 0; @@ -73,16 +75,11 @@ uc_new_salloc(size_t chunksz) if (first == NULL) { return NULL; } - p = (SAlloc *)&first->data.data[0]; + first->next = NULL; first->firstfree = sizeof *p; + + p = (SAlloc *)&first->data.data[0]; p->chunksz = chunksz; - p->current = NULL; - - if ((first = add_chunk(p, first)) == NULL) { - free(p); - return NULL; - } - p->first = p->current = first; return p;