Forráskód Böngészése

Initialize fixed lists only in the first heap.

Ioannis Koutras 13 éve
szülő
commit
540c6caa24
1 módosított fájl, 2 hozzáadás és 37 törlés
  1. 2 37
      src/initialize_allocator.c

+ 2 - 37
src/initialize_allocator.c

@@ -130,13 +130,11 @@ void initialize_allocator(allocator_t *allocator) {
 #ifdef WITH_FIXED_LISTS
 
     /* Custom number of fixed lists and their initialization
-     * 2 first ones with 32, 64, 128 and 256 (4 fixed lists per heap)
-     * 2 last ones with 64 and 256 (2 fixed lists per heap)
-     * 2 * 4 + 2 * 2 = 12 maptable nodes
+     * Fixed lists of 32, 64, 128 and 256 bytes (4 fixed lists per heap)
      */
     current_heap = &allocator->heaps[0];
 
-    maptablenode = (maptable_node_t *) sys_alloc(allocator, &allocator->heaps[0], 12*(sizeof(maptable_node_t)));
+    maptablenode = (maptable_node_t *) sys_alloc(allocator, &allocator->heaps[0], 4*(sizeof(maptable_node_t)));
 
     maptablenode->size = 32;
     maptablenode->fixed_list_head = NULL;
@@ -151,39 +149,6 @@ void initialize_allocator(allocator_t *allocator) {
     (maptablenode+3)->size = 256;
     (maptablenode+3)->fixed_list_head = NULL;
     (maptablenode+3)->next = NULL;
-    current_heap = &allocator->heaps[1];
-    maptablenode += 4;
-    maptablenode->size = 32;
-    maptablenode->fixed_list_head = NULL;
-    maptablenode->next = maptablenode+1;
-    current_heap->maptable_head = maptablenode;
-    (maptablenode+1)->size = 64;
-    (maptablenode+1)->fixed_list_head = NULL;
-    (maptablenode+1)->next = maptablenode+2;
-    (maptablenode+2)->size = 128;
-    (maptablenode+2)->fixed_list_head = NULL;
-    (maptablenode+2)->next = maptablenode+3;
-    (maptablenode+3)->size = 256;
-    (maptablenode+3)->fixed_list_head = NULL;
-    (maptablenode+3)->next = NULL;
-    current_heap = &allocator->heaps[2];
-    maptablenode += 4;
-    maptablenode->size = 64;
-    maptablenode->fixed_list_head = NULL;
-    maptablenode->next = maptablenode+1;
-    current_heap->maptable_head = maptablenode;
-    (maptablenode+1)->size = 256;
-    (maptablenode+1)->fixed_list_head = NULL;
-    (maptablenode+1)->next = NULL;
-    current_heap = &allocator->heaps[3];
-    maptablenode += 2;
-    maptablenode->size = 64;
-    maptablenode->fixed_list_head = NULL;
-    maptablenode->next = maptablenode+1;
-    current_heap->maptable_head = maptablenode;
-    (maptablenode+1)->size = 256;
-    (maptablenode+1)->fixed_list_head = NULL;
-    (maptablenode+1)->next = NULL;
 #endif /* WITH_FIXED_LISTS */
 
 #ifdef HAVE_LOCKS