X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilccore%2Fsilcidcache.c;h=a28c6833034bc19cc92c0d2073593b1612f6cb94;hb=a818c5b5411bbc4436d1c5f011236985c96bb787;hp=c4b658e80ed02f3827d06ad687de3c154e9577e1;hpb=7428855aff83c6dd40431bb88d3f1e5c973e7c06;p=silc.git diff --git a/lib/silccore/silcidcache.c b/lib/silccore/silcidcache.c index c4b658e8..a28c6833 100644 --- a/lib/silccore/silcidcache.c +++ b/lib/silccore/silcidcache.c @@ -87,9 +87,9 @@ struct SilcIDCacheStruct { struct SilcIDCacheListStruct { SilcIDCacheEntry cache[64]; SilcIDCacheEntry *cache_dyn; - uint32 cache_dyn_count; - uint32 cache_count; - uint32 pos; + SilcUInt32 cache_dyn_count; + SilcUInt32 cache_count; + SilcUInt32 pos; bool dyn; }; @@ -98,7 +98,7 @@ struct SilcIDCacheListStruct { The `id_type' defines the types of the ID's that will be saved to the cache. */ -SilcIDCache silc_idcache_alloc(uint32 count, SilcIdType id_type, +SilcIDCache silc_idcache_alloc(SilcUInt32 count, SilcIdType id_type, SilcIDCacheDestructor destructor) { SilcIDCache cache; @@ -107,9 +107,9 @@ SilcIDCache silc_idcache_alloc(uint32 count, SilcIdType id_type, cache = silc_calloc(1, sizeof(*cache)); cache->id_table = silc_hash_table_alloc(count, silc_hash_id, - (void *)(uint32)id_type, + (void *)(SilcUInt32)id_type, silc_hash_id_compare, - (void *)(uint32)id_type, + (void *)(SilcUInt32)id_type, silc_idcache_destructor, NULL, FALSE); cache->name_table = silc_hash_table_alloc(count, silc_hash_string, NULL, @@ -142,10 +142,9 @@ void silc_idcache_free(SilcIDCache cache) the entry never expires from the cache. */ bool silc_idcache_add(SilcIDCache cache, char *name, void *id, - void *context, int expire) + void *context, int expire, SilcIDCacheEntry *ret) { SilcIDCacheEntry c; - uint32 curtime = time(NULL); SILC_LOG_DEBUG(("Adding cache entry")); @@ -153,7 +152,7 @@ bool silc_idcache_add(SilcIDCache cache, char *name, void *id, c = silc_calloc(1, sizeof(*c)); c->id = id; c->name = name; - c->expire = (expire ? (curtime + SILC_ID_CACHE_EXPIRE) : 0); + c->expire = expire; c->context = context; /* Add the new entry to the hash tables */ @@ -173,6 +172,9 @@ bool silc_idcache_add(SilcIDCache cache, char *name, void *id, silc_hash_table_rehash(cache->context_table, 0); } + if (ret) + *ret = c; + return TRUE; } @@ -294,7 +296,7 @@ static void silc_idcache_purge_foreach(void *key, void *context, void *user_context) { SilcIDCache cache = (SilcIDCache)user_context; - uint32 curtime = time(NULL); + SilcUInt32 curtime = time(NULL); SilcIDCacheEntry c = (SilcIDCacheEntry)context; if (c->expire && c->expire < curtime) {