X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fhashtable%2Fhashtable.hpp;h=1feab4d39d1328d8e3de0021c4b920d35b0bade9;hb=e665dfbce25215d5ec77ff03a279c7163b337db1;hp=bd5cb948eac3a1be1f1e7a17b32c4ed2721d02fa;hpb=c9e313bc594f40a86eed237dce222c0fc99c957f;p=lttng-tools.git diff --git a/src/common/hashtable/hashtable.hpp b/src/common/hashtable/hashtable.hpp index bd5cb948e..1feab4d39 100644 --- a/src/common/hashtable/hashtable.hpp +++ b/src/common/hashtable/hashtable.hpp @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -17,8 +18,8 @@ LTTNG_EXPORT extern unsigned long lttng_ht_seed; -typedef unsigned long (*hash_fct_type)(const void *_key, unsigned long seed); -typedef cds_lfht_match_fct hash_match_fct; +using hash_fct_type = unsigned long (*)(const void *, unsigned long); +using hash_match_fct = cds_lfht_match_fct; enum lttng_ht_type { LTTNG_HT_TYPE_STRING, @@ -27,7 +28,10 @@ enum lttng_ht_type { LTTNG_HT_TYPE_TWO_U64, }; +struct lttng_ht_deleter; + struct lttng_ht { + using uptr = std::unique_ptr; struct cds_lfht *ht; cds_lfht_match_fct match_fct; hash_fct_type hash_fct; @@ -69,6 +73,9 @@ struct lttng_ht_node_two_u64 { /* Hashtable new and destroy */ struct lttng_ht *lttng_ht_new(unsigned long size, enum lttng_ht_type type); void lttng_ht_destroy(struct lttng_ht *ht); +struct lttng_ht_deleter { + void operator()(lttng_ht *ht) { lttng_ht_destroy(ht); }; +}; /* Specialized node init and free functions */ void lttng_ht_node_init_str(struct lttng_ht_node_str *node, char *key);