X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=src%2Fcommon%2Fhashtable%2Fhashtable.c;h=8d63e8afffdc60c837514359fe6b9383a27647e9;hb=702b1ea4d37c122c2622004fd4cf53175e7c7754;hp=4f64778df2d31244e319ac81f422fc5ee444339d;hpb=10a8a2237343699e3923d87e24dbf2d7fe225377;p=lttng-tools.git diff --git a/src/common/hashtable/hashtable.c b/src/common/hashtable/hashtable.c index 4f64778df..8d63e8aff 100644 --- a/src/common/hashtable/hashtable.c +++ b/src/common/hashtable/hashtable.c @@ -21,8 +21,8 @@ #include #include -#include -#include +#include +#include #include "hashtable.h" #include "utils.h" @@ -199,6 +199,28 @@ void lttng_ht_add_unique_ulong(struct lttng_ht *ht, assert(node_ptr == &node->node); } +/* + * Add replace unsigned long node to hashtable. + */ +struct lttng_ht_node_ulong *lttng_ht_add_replace_ulong(struct lttng_ht *ht, + struct lttng_ht_node_ulong *node) +{ + struct cds_lfht_node *node_ptr; + assert(ht); + assert(ht->ht); + assert(node); + + node_ptr = cds_lfht_add_replace(ht->ht, + ht->hash_fct((void *) node->key, HASH_SEED), ht->match_fct, + (void *) node->key, &node->node); + if (!node_ptr) { + return NULL; + } else { + return caa_container_of(node_ptr, struct lttng_ht_node_ulong, node); + } + assert(node_ptr == &node->node); +} + /* * Delete node from hashtable. */