Changeset 111 for trunk/lib/lru_cache.c
- Timestamp:
- 05/01/08 00:06:22 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/lru_cache.c
r108 r111 101 101 lru_cache* ret_val; 102 102 103 if(max_keys < 2)104 return NULL;105 106 103 ret_val = (lru_cache*)malloc(sizeof(lru_cache)); 107 104 if(ret_val == NULL) 108 105 return NULL; 109 106 110 ret_val->num_buckets = max_keys/lru_cache_floor_log2(max_keys); 111 if(ret_val->num_buckets < 1) 112 ret_val->num_buckets = 1; 113 107 if(max_keys == 0) 108 ret_val->num_buckets = 2048; 109 else 110 { 111 ret_val->num_buckets = max_keys/lru_cache_floor_log2(max_keys); 112 if(ret_val->num_buckets < 1) 113 ret_val->num_buckets = 1; 114 } 115 114 116 ret_val->table 115 117 = (lru_cache_element**)malloc(sizeof(lru_cache_element*) … … 193 195 { /* We didn't find an identical index. */ 194 196 195 if( ht->num_keys >= ht->max_keys)197 if((ht->max_keys != 0) && (ht->num_keys >= ht->max_keys)) 196 198 { /* Eliminate the least recently used item, but reuse the element 197 199 * structure to minimize reallocation.
Note: See TracChangeset
for help on using the changeset viewer.