add configuration for frequency of guard slabs
parent
4ee12e64e0
commit
348f9fa557
2
config.h
2
config.h
|
@ -3,11 +3,11 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
|
||||
#define GUARD_SLABS true
|
||||
#define WRITE_AFTER_FREE_CHECK true
|
||||
#define SLOT_RANDOMIZE true
|
||||
#define ZERO_ON_FREE true
|
||||
#define SLAB_CANARY true
|
||||
#define GUARD_SLABS_INTERVAL 1
|
||||
#define GUARD_SIZE_DIVISOR 2
|
||||
|
||||
#endif
|
||||
|
|
5
malloc.c
5
malloc.c
|
@ -141,6 +141,7 @@ static struct size_class {
|
|||
struct random_state rng;
|
||||
size_t metadata_allocated;
|
||||
size_t metadata_count;
|
||||
size_t metadata_count_unguarded;
|
||||
} __attribute__((aligned(CACHELINE_SIZE))) size_class_metadata[N_SIZE_CLASSES];
|
||||
|
||||
static const size_t class_region_size = 128ULL * 1024 * 1024 * 1024;
|
||||
|
@ -180,8 +181,10 @@ static struct slab_metadata *alloc_metadata(struct size_class *c, size_t slab_si
|
|||
return NULL;
|
||||
}
|
||||
c->metadata_count++;
|
||||
if (GUARD_SLABS) {
|
||||
c->metadata_count_unguarded++;
|
||||
if (c->metadata_count_unguarded >= GUARD_SLABS_INTERVAL) {
|
||||
c->metadata_count++;
|
||||
c->metadata_count_unguarded = 0;
|
||||
}
|
||||
return metadata;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue