diff --git a/config.h b/config.h index 822bf6d..0a701a7 100644 --- a/config.h +++ b/config.h @@ -5,5 +5,6 @@ #define WRITE_AFTER_FREE_CHECK true #define SLOT_RANDOMIZE true #define ZERO_ON_FREE true +#define SLAB_CANARY true #endif diff --git a/malloc.c b/malloc.c index a0cd0e4..0a5f743 100644 --- a/malloc.c +++ b/malloc.c @@ -23,7 +23,7 @@ static_assert(sizeof(void *) == 8, "64-bit only"); static_assert(!WRITE_AFTER_FREE_CHECK || ZERO_ON_FREE, "WRITE_AFTER_FREE_CHECK depends on ZERO_ON_FREE"); // either sizeof(uint64_t) or 0 -static const size_t canary_size = sizeof(uint64_t); +static const size_t canary_size = SLAB_CANARY ? sizeof(uint64_t) : 0; #define CACHELINE_SIZE 64