finish implementation of zero byte size class

This commit is contained in:
Daniel Micay 2018-08-25 02:48:47 -04:00
parent f97a0ef8b1
commit 965c3202b4

View File

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