|
@@ -0,0 +1,23 @@
|
|
|
+#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 *p1, *p2, *p3;
|
|
|
+
|
|
|
+ initialize_allocator(&systemallocator, malloc(ALLOCATOR_SIZE), 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);
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|