25 lines
549 B
C
25 lines
549 B
C
|
|
#define DEBUG
|
||
|
|
#include <stdlib.h>
|
||
|
|
#include <assert.h>
|
||
|
|
#include "../include/arena.h"
|
||
|
|
#include "../include/mem.h"
|
||
|
|
#include <string.h>
|
||
|
|
|
||
|
|
int main(void){
|
||
|
|
const size_t nbytes = 10;
|
||
|
|
char *buf[nbytes];
|
||
|
|
memset(buf,0,nbytes);
|
||
|
|
Arena a;
|
||
|
|
ARENA_BACK(&a,buf,nbytes);
|
||
|
|
assert(a.beg != NULL);
|
||
|
|
assert( mem_is_zero(a.beg, nbytes));
|
||
|
|
|
||
|
|
char *ptr = ARENA_ALLOC(0, &a, nbytes,nbytes,1);
|
||
|
|
assert(ptr != NULL);
|
||
|
|
memcpy(ptr,"abcdefghij",nbytes);
|
||
|
|
assert(memcmp(ptr, "abcdefghij", nbytes) == 0);
|
||
|
|
|
||
|
|
|
||
|
|
return EXIT_SUCCESS;
|
||
|
|
}
|