arena/tests/02_arena_new.c
2025-07-05 15:29:39 -05:00

28 lines
579 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)
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,SOFTFAIL);
ASSERTED(a.beg != NULL);
ASSERTED(isZeroed(a.beg, BUFSZ) == true);
return EXIT_SUCCESS;
}