Changeset 184 for trunk/lib/lru_cache.c


Ignore:
Timestamp:
03/20/10 13:50:44 (14 years ago)
Author:
tim
Message:

redesigned memory management to allow for multiple references to talloc-ed objects

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/lru_cache.c

    r169 r184  
    119119  if(max_keys == 0)
    120120    ret_val->num_buckets = 1024;
     121  else if(max_keys == 1)
     122    ret_val->num_buckets = 1;   
    121123  else
    122124  {
     
    125127      ret_val->num_buckets = 1;
    126128  }
    127 
     129 
    128130  ret_val->table = talloc_array(ret_val,
    129131                                lru_cache_element*, ret_val->num_buckets);
     
    177179     */
    178180    if(ht->talloc_data)
    179       talloc_free(e->data);
     181      talloc_unlink(e, e->data);
    180182
    181183    if(e->newer == NULL)
     
    224226
    225227      if(ht->talloc_data)
    226         talloc_free(e->data);
     228        talloc_unlink(e, e->data);
    227229
    228230      tmp_index = talloc_realloc_size(e, e->index, index_len);
     
    261263  e->data = data;
    262264  if(ht->talloc_data)
    263     talloc_steal(e, e->data);
     265    talloc_reference(e, e->data);
    264266
    265267  /* Finally, let's insert the element to the newest position in the LRU list.*/
Note: See TracChangeset for help on using the changeset viewer.