Changeset 111 for trunk/lib/lru_cache.c


Ignore:
Timestamp:
05/01/08 00:06:22 (16 years ago)
Author:
tim
Message:

Switched license to GPLv3

Added early version of new tool, reglookup-recover

Many library changes made to support this new tool

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/lru_cache.c

    r108 r111  
    101101  lru_cache* ret_val;
    102102
    103   if(max_keys < 2)
    104     return NULL;
    105 
    106103  ret_val = (lru_cache*)malloc(sizeof(lru_cache));
    107104  if(ret_val == NULL)
    108105    return NULL;
    109106
    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
    114116  ret_val->table
    115117    = (lru_cache_element**)malloc(sizeof(lru_cache_element*)
     
    193195  { /* We didn't find an identical index. */
    194196   
    195     if(ht->num_keys >= ht->max_keys)
     197    if((ht->max_keys != 0) && (ht->num_keys >= ht->max_keys))
    196198    { /* Eliminate the least recently used item, but reuse the element
    197199       * structure to minimize reallocation.
Note: See TracChangeset for help on using the changeset viewer.