tweak canary awareness in offset test

pull/65/head
Daniel Micay 2018-10-19 16:17:38 -04:00
parent 64b655f062
commit 1d2c10f5bb
1 changed files with 8 additions and 5 deletions

View File

@ -2,7 +2,9 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
static const unsigned size_classes[] = { #include "../config.h"
static unsigned size_classes[] = {
/* large */ 4 * 1024 * 1024, /* large */ 4 * 1024 * 1024,
/* 0 */ 0, /* 0 */ 0,
/* 16 */ 16, 32, 48, 64, 80, 96, 112, 128, /* 16 */ 16, 32, 48, 64, 80, 96, 112, 128,
@ -17,15 +19,16 @@ static const unsigned size_classes[] = {
#define N_SIZE_CLASSES (sizeof(size_classes) / sizeof(size_classes[0])) #define N_SIZE_CLASSES (sizeof(size_classes) / sizeof(size_classes[0]))
static size_t canary_size = 8; static const size_t canary_size = SLAB_CANARY ? sizeof(uint64_t) : 0;
int main(void) { int main(void) {
for (unsigned i = 2; i < N_SIZE_CLASSES; i++) {
size_classes[i] -= canary_size;
}
void *p[N_SIZE_CLASSES]; void *p[N_SIZE_CLASSES];
for (unsigned i = 0; i < N_SIZE_CLASSES; i++) { for (unsigned i = 0; i < N_SIZE_CLASSES; i++) {
unsigned size = size_classes[i]; unsigned size = size_classes[i];
if (size) {
size -= canary_size;
}
p[i] = malloc(size); p[i] = malloc(size);
if (!p) { if (!p) {
return 1; return 1;