Browse Source

Free the memory from malloc() in the test_for_memory_space_aware example.

Ioannis Koutras 13 years ago
parent
commit
5a57ee5f2c
1 changed files with 6 additions and 2 deletions
  1. 6 2
      examples/test_for_memory_space_aware.c

+ 6 - 2
examples/test_for_memory_space_aware.c

@@ -8,9 +8,11 @@
 int main(void) {
 
     allocator_t systemallocator;
+    void *block_from_malloc;
     void *p1, *p2, *p3;
-    
-    initialize_allocator(&systemallocator, malloc(ALLOCATOR_SIZE), ALLOCATOR_SIZE);
+
+    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);
@@ -19,5 +21,7 @@ int main(void) {
     custom_ahfree(&systemallocator, &systemallocator.heaps[0], p2);
     custom_ahfree(&systemallocator, &systemallocator.heaps[0], p3);
 
+    free(block_from_malloc);
+
     return 0;
 }