Refactor SAlloc

This commit is contained in:
Nils O. Selåsdal
2025-07-05 20:09:12 +02:00
parent 1f6dee3a9a
commit 97bf06b2e8
+5 -8
View File
@@ -39,6 +39,8 @@ add_chunk(SAlloc *p, Chunk *c)
if (c == NULL) if (c == NULL)
return c; return c;
p->current->next = c;
c->next = NULL; c->next = NULL;
c->firstfree = 0; c->firstfree = 0;
@@ -73,16 +75,11 @@ uc_new_salloc(size_t chunksz)
if (first == NULL) { if (first == NULL) {
return NULL; return NULL;
} }
p = (SAlloc *)&first->data.data[0]; first->next = NULL;
first->firstfree = sizeof *p; first->firstfree = sizeof *p;
p = (SAlloc *)&first->data.data[0];
p->chunksz = chunksz; p->chunksz = chunksz;
p->current = NULL;
if ((first = add_chunk(p, first)) == NULL) {
free(p);
return NULL;
}
p->first = p->current = first; p->first = p->current = first;
return p; return p;