|
|
@ -1,6 +1,30 @@ |
|
|
|
#include <stdio.h> |
|
|
|
#include <stdint.h> |
|
|
|
#include <stddef.h> |
|
|
|
#include <unistd.h> |
|
|
|
#include <sys/mman.h> |
|
|
|
|
|
|
|
#include "alloc_api.h" |
|
|
|
|
|
|
|
void *get_new_region(uintptr_t size) { |
|
|
|
void *m = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); |
|
|
|
if (m == MAP_FAILED) { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
return m; |
|
|
|
} |
|
|
|
|
|
|
|
void error(char *msg) { |
|
|
|
printf("=== ALLOCATOR ERROR ===\n%s\n====== END ERROR ======\n", msg); |
|
|
|
} |
|
|
|
|
|
|
|
int main() { |
|
|
|
printf("Hello, World!\n"); |
|
|
|
struct Arena arena = { |
|
|
|
NULL, |
|
|
|
NULL, |
|
|
|
get_new_region, |
|
|
|
error, |
|
|
|
}; |
|
|
|
return 0; |
|
|
|
} |