12345678910111213141516171819202122232425262728 |
- #include <stdio.h>
- #include <stdlib.h>
- #include <dmmlib/initialize_allocator.h>
- #include <dmmlib/dmmlib.h>
- #define ALLOCATOR_SIZE 16*1024*sizeof(char)
- int main(void) {
- allocator_t systemallocator;
- void *block_from_malloc;
- void *p1, *p2, *p3;
- block_from_malloc = malloc(ALLOCATOR_SIZE);
- initialize_allocator(&systemallocator, block_from_malloc, ALLOCATOR_SIZE);
- p1 = custom_ahmalloc(&systemallocator, &systemallocator.heaps[0], (size_t) 1024);
- custom_ahfree(&systemallocator, &systemallocator.heaps[0], p1);
- p2 = custom_ahmalloc(&systemallocator, &systemallocator.heaps[0], (size_t) 512);
- p3 = custom_ahmalloc(&systemallocator, &systemallocator.heaps[0], (size_t) 394);
- custom_ahfree(&systemallocator, &systemallocator.heaps[0], p2);
- custom_ahfree(&systemallocator, &systemallocator.heaps[0], p3);
- free(block_from_malloc);
- return 0;
- }
|