alloc: simplify full usage

This commit is contained in:
Mathieu Maret 2021-01-26 08:45:13 +01:00
parent 9e5b4f0060
commit 3b7543064d

View File

@ -217,9 +217,8 @@ static void *allocFromSlab(struct slabEntry *slab)
if (*next == (vaddr_t)NULL) { if (*next == (vaddr_t)NULL) {
pr_devel("Slab @%d is now full\n", slab); pr_devel("Slab @%d is now full\n", slab);
slab->full = 1; slab->full = 1;
} else {
slab->freeEl = (void *)(*next);
} }
slab->freeEl = (void *)(*next);
return (void *)next; return (void *)next;
} }
@ -289,12 +288,7 @@ static int freeFromSlab(void *ptr, struct slabEntry *slab)
if ((slabEntry->page <= (vaddr_t)ptr) && if ((slabEntry->page <= (vaddr_t)ptr) &&
((vaddr_t)ptr < (slabEntry->page + slabEntry->size))) { ((vaddr_t)ptr < (slabEntry->page + slabEntry->size))) {
if (slabEntry->full) {
*((vaddr_t *)ptr) = (vaddr_t)NULL;
} else {
*((vaddr_t *)ptr) = (vaddr_t)slabEntry->freeEl; *((vaddr_t *)ptr) = (vaddr_t)slabEntry->freeEl;
}
slabEntry->freeEl = ptr; slabEntry->freeEl = ptr;
slabEntry->full = 0; slabEntry->full = 0;
return 1; return 1;