finish implementation of zero byte size class

pull/50/head
Daniel Micay 2018-08-25 02:48:47 -04:00
parent f97a0ef8b1
commit 965c3202b4
1 changed files with 7 additions and 1 deletions

View File

@ -379,6 +379,10 @@ static void slab_free(void *p) {
struct size_class *c = &size_class_metadata[class];
size_t size = size_classes[class];
bool is_zero_size = size == 0;
if (is_zero_size) {
size = 16;
}
size_t slots = size_class_slots[class];
size_t slab_size = get_slab_size(slots, size);
@ -407,7 +411,9 @@ static void slab_free(void *p) {
}
clear_slot(metadata, slot);
if (!is_zero_size) {
memset(p, 0, size);
}
if (is_free_slab(metadata)) {
if (metadata->prev) {