projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
common: replace container_of with a C++ safe implementation
[lttng-tools.git]
/
src
/
common
/
hashtable
/
hashtable.cpp
diff --git
a/src/common/hashtable/hashtable.cpp
b/src/common/hashtable/hashtable.cpp
index 7112debf28eae58a63bc6bb7d367ffac81f6a6c1..3aa3d79d42210dcfb192a21056c1a1a2319c7716 100644
(file)
--- a/
src/common/hashtable/hashtable.cpp
+++ b/
src/common/hashtable/hashtable.cpp
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (C) 2011
David Goulet <david.goulet@polymtl.ca>
+ * Copyright (C) 2011
EfficiOS Inc.
*
* SPDX-License-Identifier: GPL-2.0-only
*
*
* SPDX-License-Identifier: GPL-2.0-only
*
@@
-10,16
+10,15
@@
#include <urcu.h>
#include <urcu/compiler.h>
#include <urcu.h>
#include <urcu/compiler.h>
-#include <common/common.h>
-#include <common/defaults.h>
+#include <common/common.h
pp
>
+#include <common/defaults.h
pp
>
-#include "hashtable.h"
-#include "utils.h"
+#include "hashtable.h
pp
"
+#include "utils.h
pp
"
/* seed_lock protects both seed_init and lttng_ht_seed. */
static pthread_mutex_t seed_lock = PTHREAD_MUTEX_INITIALIZER;
static bool seed_init;
/* 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;
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 =
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);
}
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 =
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);
}
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 =
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);
}
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 =
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);
}
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);
}
pthread_mutex_unlock(&seed_lock);
- ht =
(lttng_ht *) zmalloc(sizeof(*ht)
);
+ ht =
zmalloc<lttng_ht>(
);
if (ht == NULL) {
PERROR("zmalloc lttng_ht");
goto error;
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 {
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);
}
}
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 {
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);
}
}
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;
}
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;
}
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;
}
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;
}
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);
}
}
This page took
0.025914 seconds
and
4
git commands to generate.