|
55 | 55 | #include "nl-priv-dynamic-core/nl-core.h" |
56 | 56 | #include "nl-priv-dynamic-core/object-api.h" |
57 | 57 | #include "nl-priv-dynamic-core/cache-api.h" |
| 58 | +#include "hashtable-api.h" |
58 | 59 | #include "nl-aux-core/nl-core.h" |
59 | 60 |
|
60 | 61 | /** |
@@ -200,14 +201,7 @@ struct nl_cache *nl_cache_alloc(struct nl_cache_ops *ops) |
200 | 201 | * cache objects for faster lookups |
201 | 202 | */ |
202 | 203 | if (ops->co_obj_ops->oo_keygen) { |
203 | | - int hashtable_size; |
204 | | - |
205 | | - if (ops->co_hash_size) |
206 | | - hashtable_size = ops->co_hash_size; |
207 | | - else |
208 | | - hashtable_size = NL_MAX_HASH_ENTRIES; |
209 | | - |
210 | | - cache->hashtable = nl_hash_table_alloc(hashtable_size); |
| 204 | + cache->hashtable = nl_rhash_table_alloc(); |
211 | 205 | } |
212 | 206 |
|
213 | 207 | NL_DBG(2, "Allocated cache %p <%s>.\n", cache, nl_cache_name(cache)); |
@@ -379,7 +373,7 @@ static void __nl_cache_free(struct nl_cache *cache) |
379 | 373 | nl_cache_clear(cache); |
380 | 374 |
|
381 | 375 | if (cache->hashtable) |
382 | | - nl_hash_table_free(cache->hashtable); |
| 376 | + nl_rhash_table_free(cache->hashtable); |
383 | 377 |
|
384 | 378 | NL_DBG(2, "Freeing cache %p <%s>...\n", cache, nl_cache_name(cache)); |
385 | 379 | free(cache); |
@@ -439,7 +433,7 @@ static int __cache_add(struct nl_cache *cache, struct nl_object *obj) |
439 | 433 | obj->ce_cache = cache; |
440 | 434 |
|
441 | 435 | if (cache->hashtable) { |
442 | | - ret = nl_hash_table_add(cache->hashtable, obj); |
| 436 | + ret = nl_rhash_table_add(cache->hashtable, obj); |
443 | 437 | if (ret < 0) { |
444 | 438 | obj->ce_cache = NULL; |
445 | 439 | return ret; |
@@ -558,7 +552,7 @@ void nl_cache_remove(struct nl_object *obj) |
558 | 552 | return; |
559 | 553 |
|
560 | 554 | if (cache->hashtable) { |
561 | | - ret = nl_hash_table_del(cache->hashtable, obj); |
| 555 | + ret = nl_rhash_table_del(cache->hashtable, obj); |
562 | 556 | if (ret < 0) |
563 | 557 | NL_DBG(2, "Failed to delete %p from cache %p <%s>.\n", |
564 | 558 | obj, cache, nl_cache_name(cache)); |
@@ -1095,7 +1089,7 @@ static struct nl_object *__cache_fast_lookup(struct nl_cache *cache, |
1095 | 1089 | { |
1096 | 1090 | struct nl_object *obj; |
1097 | 1091 |
|
1098 | | - obj = nl_hash_table_lookup(cache->hashtable, needle); |
| 1092 | + obj = nl_rhash_table_lookup(cache->hashtable, needle); |
1099 | 1093 | if (obj) { |
1100 | 1094 | nl_object_get(obj); |
1101 | 1095 | return obj; |
|
0 commit comments