projects
/
silc.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Integer type name change.
[silc.git]
/
lib
/
silccore
/
silcidcache.c
diff --git
a/lib/silccore/silcidcache.c
b/lib/silccore/silcidcache.c
index b922beb7f9cdfca9af3529062572c11b9c6b421b..a28c6833034bc19cc92c0d2073593b1612f6cb94 100644
(file)
--- a/
lib/silccore/silcidcache.c
+++ b/
lib/silccore/silcidcache.c
@@
-87,9
+87,9
@@
struct SilcIDCacheStruct {
struct SilcIDCacheListStruct {
SilcIDCacheEntry cache[64];
SilcIDCacheEntry *cache_dyn;
struct SilcIDCacheListStruct {
SilcIDCacheEntry cache[64];
SilcIDCacheEntry *cache_dyn;
-
ui
nt32 cache_dyn_count;
-
ui
nt32 cache_count;
-
ui
nt32 pos;
+
SilcUI
nt32 cache_dyn_count;
+
SilcUI
nt32 cache_count;
+
SilcUI
nt32 pos;
bool dyn;
};
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. */
The `id_type' defines the types of the ID's that will be saved to the
cache. */
-SilcIDCache silc_idcache_alloc(
ui
nt32 count, SilcIdType id_type,
+SilcIDCache silc_idcache_alloc(
SilcUI
nt32 count, SilcIdType id_type,
SilcIDCacheDestructor destructor)
{
SilcIDCache cache;
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,
cache = silc_calloc(1, sizeof(*cache));
cache->id_table = silc_hash_table_alloc(count, silc_hash_id,
- (void *)(
ui
nt32)id_type,
+ (void *)(
SilcUI
nt32)id_type,
silc_hash_id_compare,
silc_hash_id_compare,
- (void *)(
ui
nt32)id_type,
+ (void *)(
SilcUI
nt32)id_type,
silc_idcache_destructor, NULL,
FALSE);
cache->name_table = silc_hash_table_alloc(count, silc_hash_string, NULL,
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,
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;
{
SilcIDCacheEntry c;
- uint32 curtime = time(NULL);
SILC_LOG_DEBUG(("Adding cache entry"));
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 = 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 */
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);
}
silc_hash_table_rehash(cache->context_table, 0);
}
+ if (ret)
+ *ret = c;
+
return TRUE;
}
return TRUE;
}
@@
-198,6
+200,8
@@
bool silc_idcache_del(SilcIDCache cache, SilcIDCacheEntry old)
ret = silc_hash_table_del(cache->context_table, old->context);
if (old->id)
ret = silc_hash_table_del(cache->id_table, old->id);
ret = silc_hash_table_del(cache->context_table, old->context);
if (old->id)
ret = silc_hash_table_del(cache->id_table, old->id);
+ else
+ silc_free(old);
return ret;
}
return ret;
}
@@
-263,6
+267,8
@@
bool silc_idcache_del_by_context(SilcIDCache cache, void *context)
ret = silc_hash_table_del(cache->context_table, c->context);
if (c->id)
ret = silc_hash_table_del_by_context(cache->id_table, c->id, c);
ret = silc_hash_table_del(cache->context_table, c->context);
if (c->id)
ret = silc_hash_table_del_by_context(cache->id_table, c->id, c);
+ else
+ silc_free(c);
return ret;
}
return ret;
}
@@
-290,7
+296,7
@@
static void silc_idcache_purge_foreach(void *key, void *context,
void *user_context)
{
SilcIDCache cache = (SilcIDCache)user_context;
void *user_context)
{
SilcIDCache cache = (SilcIDCache)user_context;
-
ui
nt32 curtime = time(NULL);
+
SilcUI
nt32 curtime = time(NULL);
SilcIDCacheEntry c = (SilcIDCacheEntry)context;
if (c->expire && c->expire < curtime) {
SilcIDCacheEntry c = (SilcIDCacheEntry)context;
if (c->expire && c->expire < curtime) {