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;