Ignore:
Timestamp:
May 26, 2009, 9:44:50 AM (16 years ago)
Author:
Herwig Bauernfeind
Message:

Update 3.2 branch to 3.2.6

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.2.x/source/lib/memcache.c

    r136 r228  
    215215        DLIST_REMOVE(cache->mru, e);
    216216
     217        if (memcache_is_talloc(e->n)) {
     218                DATA_BLOB cache_key, cache_value;
     219                void *ptr;
     220
     221                memcache_element_parse(e, &cache_key, &cache_value);
     222                SMB_ASSERT(cache_value.length == sizeof(ptr));
     223                memcpy(&ptr, cache_value.data, sizeof(ptr));
     224                TALLOC_FREE(ptr);
     225        }
     226
    217227        cache->size -= memcache_element_size(e->keylength, e->valuelength);
    218228
     
    277287
    278288                if (value.length <= cache_value.length) {
     289                        if (memcache_is_talloc(e->n)) {
     290                                void *ptr;
     291                                SMB_ASSERT(cache_value.length == sizeof(ptr));
     292                                memcpy(&ptr, cache_value.data, sizeof(ptr));
     293                                TALLOC_FREE(ptr);
     294                        }
    279295                        /*
    280296                         * We can reuse the existing record
     
    333349
    334350void memcache_add_talloc(struct memcache *cache, enum memcache_number n,
    335                          DATA_BLOB key, void *ptr)
    336 {
    337         memcache_add(cache, n, key, data_blob_const(&ptr, sizeof(ptr)));
     351                         DATA_BLOB key, void *pptr)
     352{
     353        void **ptr = (void **)pptr;
     354        void *p;
     355
     356        if (cache == NULL) {
     357                cache = global_cache;
     358        }
     359        if (cache == NULL) {
     360                return;
     361        }
     362
     363        p = talloc_move(cache, ptr);
     364        memcache_add(cache, n, key, data_blob_const(&p, sizeof(p)));
    338365}
    339366
Note: See TracChangeset for help on using the changeset viewer.