X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fhashtable%2Fhashtable.cpp;h=3aa3d79d42210dcfb192a21056c1a1a2319c7716;hb=0114db0ec2407029052eb61a0189c9b1cd64d520;hp=7112debf28eae58a63bc6bb7d367ffac81f6a6c1;hpb=6dca8ba7dec3b31acb7b43f5e4431676acf4e664;p=lttng-tools.git diff --git a/src/common/hashtable/hashtable.cpp b/src/common/hashtable/hashtable.cpp index 7112debf2..3aa3d79d4 100644 --- a/src/common/hashtable/hashtable.cpp +++ b/src/common/hashtable/hashtable.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 David Goulet + * Copyright (C) 2011 EfficiOS Inc. * * SPDX-License-Identifier: GPL-2.0-only * @@ -10,16 +10,15 @@ #include #include -#include -#include +#include +#include -#include "hashtable.h" -#include "utils.h" +#include "hashtable.hpp" +#include "utils.hpp" /* seed_lock protects both seed_init and lttng_ht_seed. */ static pthread_mutex_t seed_lock = PTHREAD_MUTEX_INITIALIZER; static bool seed_init; -unsigned long lttng_ht_seed; static unsigned long min_hash_alloc_size = 1; static unsigned long max_hash_buckets_size = 0; @@ -37,7 +36,7 @@ static unsigned long max_hash_buckets_size = 0; static int match_str(struct cds_lfht_node *node, const void *key) { struct lttng_ht_node_str *match_node = - caa_container_of(node, struct lttng_ht_node_str, node); + lttng::utils::container_of(node, <tng_ht_node_str::node); return hash_match_key_str(match_node->key, (void *) key); } @@ -48,7 +47,7 @@ static int match_str(struct cds_lfht_node *node, const void *key) static int match_ulong(struct cds_lfht_node *node, const void *key) { struct lttng_ht_node_ulong *match_node = - caa_container_of(node, struct lttng_ht_node_ulong, node); + lttng::utils::container_of(node, <tng_ht_node_ulong::node); return hash_match_key_ulong((void *) match_node->key, (void *) key); } @@ -59,7 +58,7 @@ static int match_ulong(struct cds_lfht_node *node, const void *key) static int match_u64(struct cds_lfht_node *node, const void *key) { struct lttng_ht_node_u64 *match_node = - caa_container_of(node, struct lttng_ht_node_u64, node); + lttng::utils::container_of(node, <tng_ht_node_u64::node); return hash_match_key_u64(&match_node->key, (void *) key); } @@ -70,7 +69,7 @@ static int match_u64(struct cds_lfht_node *node, const void *key) static int match_two_u64(struct cds_lfht_node *node, const void *key) { struct lttng_ht_node_two_u64 *match_node = - caa_container_of(node, struct lttng_ht_node_two_u64, node); + lttng::utils::container_of(node, <tng_ht_node_two_u64::node); return hash_match_key_two_u64((void *) &match_node->key, (void *) key); } @@ -111,7 +110,7 @@ struct lttng_ht *lttng_ht_new(unsigned long size, lttng_ht_type type) } pthread_mutex_unlock(&seed_lock); - ht = (lttng_ht *) zmalloc(sizeof(*ht)); + ht = zmalloc(); if (ht == NULL) { PERROR("zmalloc lttng_ht"); goto error; @@ -414,7 +413,7 @@ struct lttng_ht_node_ulong *lttng_ht_add_replace_ulong(struct lttng_ht *ht, if (!node_ptr) { return NULL; } else { - return caa_container_of(node_ptr, struct lttng_ht_node_ulong, node); + return lttng::utils::container_of(node_ptr, <tng_ht_node_ulong::node); } LTTNG_ASSERT(node_ptr == &node->node); } @@ -439,7 +438,7 @@ struct lttng_ht_node_u64 *lttng_ht_add_replace_u64(struct lttng_ht *ht, if (!node_ptr) { return NULL; } else { - return caa_container_of(node_ptr, struct lttng_ht_node_u64, node); + return lttng::utils::container_of(node_ptr, <tng_ht_node_u64::node); } LTTNG_ASSERT(node_ptr == &node->node); } @@ -518,7 +517,7 @@ struct lttng_ht_node_str *lttng_ht_iter_get_node_str( if (!node) { return NULL; } - return caa_container_of(node, struct lttng_ht_node_str, node); + return lttng::utils::container_of(node, <tng_ht_node_str::node); } /* @@ -534,7 +533,7 @@ struct lttng_ht_node_ulong *lttng_ht_iter_get_node_ulong( if (!node) { return NULL; } - return caa_container_of(node, struct lttng_ht_node_ulong, node); + return lttng::utils::container_of(node, <tng_ht_node_ulong::node); } /* @@ -550,7 +549,7 @@ struct lttng_ht_node_u64 *lttng_ht_iter_get_node_u64( if (!node) { return NULL; } - return caa_container_of(node, struct lttng_ht_node_u64, node); + return lttng::utils::container_of(node, <tng_ht_node_u64::node); } /* @@ -566,5 +565,5 @@ struct lttng_ht_node_two_u64 *lttng_ht_iter_get_node_two_u64( if (!node) { return NULL; } - return caa_container_of(node, struct lttng_ht_node_two_u64, node); + return lttng::utils::container_of(node, <tng_ht_node_two_u64::node); }