Browse Source

push_block() sets now the proper pointers.

Ioannis Koutras 13 years ago
parent
commit
a31c78ae81
2 changed files with 6 additions and 5 deletions
  1. 2 2
      examples/test_for_memory_space_aware.c
  2. 4 3
      src/linked_lists/linked_lists.c

+ 2 - 2
examples/test_for_memory_space_aware.c

@@ -15,10 +15,10 @@ int main(void) {
     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], p1);
     custom_ahfree(&systemallocator, &systemallocator.heaps[0], p2);
+    p3 = custom_ahmalloc(&systemallocator, &systemallocator.heaps[0], (size_t) 948);
     custom_ahfree(&systemallocator, &systemallocator.heaps[0], p3);
 
     free(block_from_malloc);

+ 4 - 3
src/linked_lists/linked_lists.c

@@ -45,13 +45,14 @@ void push_block(void **block, void **starting_node) {
 #ifdef BLOCKS_IN_DLL
         set_previous(*starting_node, *block);
 #endif /* BLOCKS_IN_DLL */
-        set_next(*starting_node, *block);
+        set_next(*block, *starting_node);
+    } else {
+       set_next(*block, NULL);
     }
 #ifdef BLOCKS_IN_DLL
     set_previous(*block, NULL);
 #endif /* BLOCKS_IN_DLL */
-    set_next(*block, NULL);
-    *starting_node = *block;
+     *starting_node = *block;
 }
 
 #ifdef BLOCKS_IN_SLL