test_for_memory_space_aware.c 795 B

123456789101112131415161718192021222324
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <dmmlib/initialize_allocator.h>
  4. #include <dmmlib/dmmlib.h>
  5. #define ALLOCATOR_SIZE 16*1024*sizeof(char)
  6. int main(void) {
  7. allocator_t systemallocator;
  8. void *p1, *p2, *p3;
  9. initialize_allocator(&systemallocator, malloc(ALLOCATOR_SIZE), ALLOCATOR_SIZE);
  10. p1 = custom_ahmalloc(&systemallocator, &systemallocator.heaps[0], (size_t) 1024);
  11. custom_ahfree(&systemallocator, &systemallocator.heaps[0], p1);
  12. p2 = custom_ahmalloc(&systemallocator, &systemallocator.heaps[0], (size_t) 512);
  13. p3 = custom_ahmalloc(&systemallocator, &systemallocator.heaps[0], (size_t) 394);
  14. custom_ahfree(&systemallocator, &systemallocator.heaps[0], p2);
  15. custom_ahfree(&systemallocator, &systemallocator.heaps[0], p3);
  16. return 0;
  17. }