31 lines
734 B
C
31 lines
734 B
C
#define DEBUG
|
|
#include <stdio.h>
|
|
#include "../include/arena.h"
|
|
#include "../include/except.h"
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include <stdbool.h>
|
|
|
|
#define BUFSZ MB(20)
|
|
#define ASIZE MB(1)
|
|
|
|
static bool isZeroed(void *memory, unsigned int size){
|
|
unsigned char *mm = (unsigned char*)memory;
|
|
|
|
// early out for empty size
|
|
if (size == 0) return true;
|
|
|
|
return (*mm == 0) && memcmp(mm, mm + 1, size - 1) == 0;
|
|
}
|
|
|
|
int main(void){
|
|
|
|
Arena a = arena_new(BUFSZ, NOZERO | SOFTFAIL);
|
|
ASSERTED(a.beg != NULL);
|
|
ASSERTED(isZeroed(a.beg, BUFSZ) == false);
|
|
char *ptr = arena_alloc(&a, ASIZE, 1, 2, NOZERO);
|
|
ASSERTED(ptr != NULL);
|
|
ASSERTED(isZeroed(ptr,ASIZE ) == false);
|
|
return EXIT_SUCCESS;
|
|
}
|