| 69 | } |
| 70 | |
| 71 | void init_mem_alloc(mem_allocator_t *mem_alloc) { |
| 72 | pthread_mutex_init(&mem_alloc->mtx, NULL); |
| 73 | pthread_mutex_lock(&mem_alloc->mtx); |
| 74 | // mem_alloc->cache_obj_mem_arena[0] = g_new0(cache_obj_t, N_OBJ_MEM_ARENA); |
| 75 | // mem_alloc->cache_obj_mem_arena[0] = (cache_obj_t*) malloc(MEM_ARENA_SIZE); |
| 76 | |
| 77 | mem_alloc->cache_obj_mem_arena[0] = (cache_obj_t*) _allocate_memory(MEM_ARENA_SIZE); |
| 78 | mem_alloc->cur_arena_idx = 0; |
| 79 | mem_alloc->idx_in_cur_arena = 0; |
| 80 | mem_alloc->free_list = g_queue_new(); |
| 81 | VERBOSE("init mem_alloc %p - free_list %p\n", mem_alloc, mem_alloc->free_list); |
| 82 | pthread_mutex_unlock(&mem_alloc->mtx); |
| 83 | } |
| 84 | |
| 85 | void free_mem_alloc(mem_allocator_t *mem_alloc) { |
| 86 | pthread_mutex_lock(&mem_alloc->mtx); |
no test coverage detected