| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 | 
							- #include <unistd.h>
 
- #include "dmm_config.h"
 
- #ifdef HAVE_LOCKS
 
- #include <pthread.h>
 
- #endif /* HAVE_LOCKS */
 
- #include "dmm_init.h"
 
- void dmm_init(allocator_t *allocator) {
 
-     int i;
 
-     heap_t *current_heap;
 
-     maptable_node_t *maptablenode;
 
-     for(i = 0; i < NUM_HEAPS; i++) {
 
-         allocator->heaps[i].maptable_head = NULL;
 
-         allocator->heaps[i].free_list_head = NULL;
 
-         allocator->heaps[i].used_blocks_head = NULL;
 
-         allocator->heaps[i].rov_ptr = NULL;
 
-         allocator->heaps[i].num_objects = 0;
 
-         allocator->heaps[i].dmm_stats.mem_allocated = 0;
 
-         allocator->heaps[i].dmm_stats.mem_requested = 0;
 
-         allocator->heaps[i].dmm_stats.live_objects = 0;
 
-         allocator->heaps[i].dmm_stats.num_malloc = 0;
 
-         allocator->heaps[i].dmm_stats.num_free = 0;
 
-         // Knobs initialization
 
-         allocator->heaps[i].dmm_knobs.max_coalesce_size = -1;
 
-         // FIXME Create a constant for the initial value of the next
 
-         // variables
 
-         allocator->heaps[i].dmm_knobs.frag_threshold = 1.0;
 
-         allocator->heaps[i].dmm_knobs.mem_threshold = 17000;
 
- #ifdef HAVE_LOCKS
 
-         pthread_mutex_init(&allocator->heaps[i].mutex, NULL);
 
- #endif /* HAVE_LOCKS */
 
-     }
 
-     // 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
 
-     current_heap = &allocator->heaps[0];
 
-     maptablenode = (maptable_node_t *) sbrk((int)(12*(sizeof(maptable_node_t))));
 
-     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[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;
 
- }
 
 
  |