#include <memblk.h>
Definition at line 94 of file memblk.h.
MALLOC_CALL::MALLOC_CALL | ( | ) | [inline] |
void MALLOC_CALL::count_freeer | ( | void * | addr | ) |
Generate a hash code for a freeer, setup the tables if necessary.
Then count the call.
Definition at line 157 of file memblk.cpp.
References FREE_CALL::count, free_bits, free_list, FREE_CALL::freeer, hash(), init_freeers(), and NULL.
Referenced by MEM_ALLOCATOR::dealloc().
00159 { 00160 INT32 entries; //entries in table 00161 INT32 index; //index to table 00162 INT32 initial_hash; //initial index 00163 00164 if (free_list == NULL) 00165 init_freeers(); //setup table 00166 entries = 1 << free_bits; 00167 //get hash code 00168 initial_hash = hash (free_bits, &addr, sizeof (addr)); 00169 if (initial_hash == 0) 00170 initial_hash = 1; 00171 index = initial_hash; 00172 if (free_list[index].freeer != NULL && free_list[index].freeer != addr) { 00173 do { 00174 index++; 00175 if (index >= entries) 00176 index = 1; 00177 } 00178 while (free_list[index].freeer != NULL 00179 && free_list[index].freeer != addr && index != initial_hash); 00180 if (index == initial_hash) 00181 index = 0; 00182 } 00183 if (free_list[index].freeer == NULL && index != 0) { 00184 free_list[index].freeer = addr; 00185 } 00186 free_list[index].count++; //count them 00187 }
void MALLOC_CALL::init_freeers | ( | ) |
Initialize the freeers hash table.
Definition at line 208 of file memblk.cpp.
References free_bits, and free_list.
Referenced by count_freeer(), and MEM_ALLOCATOR::hash_caller().
00208 { //setup hash table 00209 INT32 entries; //entries in table 00210 INT32 depth = mem_mallocdepth; 00211 00212 mem_mallocdepth.set_value (0); //can't register it 00213 free_bits = mem_freebits; 00214 entries = 1 << free_bits; 00215 //make an array 00216 free_list = new FREE_CALL[entries]; 00217 mem_mallocdepth.set_value (depth); 00218 }
void* MALLOC_CALL::caller |
Definition at line 97 of file memblk.h.
Referenced by MEM_ALLOCATOR::hash_caller(), and MALLOC_CALL().
Definition at line 99 of file memblk.h.
Referenced by MEM_ALLOCATOR::display_counts(), and MALLOC_CALL().
Definition at line 100 of file memblk.h.
Referenced by count_freeer(), init_freeers(), and MALLOC_CALL().
Definition at line 98 of file memblk.h.
Referenced by count_freeer(), init_freeers(), and MALLOC_CALL().