From fb5d9331e2db16f259d2f7a717a87fd93eb07864 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Thu, 29 Mar 2012 00:28:10 -0400 Subject: [PATCH] ck_ht: Add ck_ht_entry_empty function. Function returns true if the initialized ck_ht_entry_t pointed to by its argument does not contain a key-value pair. --- include/ck_ht.h | 10 ++++++++++ src/ck_ht.c | 3 --- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/include/ck_ht.h b/include/ck_ht.h index adcae67..47e7d79 100644 --- a/include/ck_ht.h +++ b/include/ck_ht.h @@ -52,6 +52,9 @@ struct ck_ht_entry { } CK_CC_ALIGNED; typedef struct ck_ht_entry ck_ht_entry_t; +#define CK_HT_KEY_EMPTY ((uintptr_t)0) +#define CK_HT_KEY_TOMBSTONE (~(uintptr_t)0) + struct ck_ht_map; struct ck_ht { struct ck_ht_map *map; @@ -77,6 +80,13 @@ ck_ht_iterator_init(struct ck_ht_iterator *iterator) return; } +CK_CC_INLINE static bool +ck_ht_entry_empty(ck_ht_entry_t *entry) +{ + + return entry->key == CK_HT_KEY_EMPTY; +} + CK_CC_INLINE static void ck_ht_entry_key_set(ck_ht_entry_t *entry, const void *key, uint16_t key_length) { diff --git a/src/ck_ht.c b/src/ck_ht.c index 6464736..07e40a1 100644 --- a/src/ck_ht.c +++ b/src/ck_ht.c @@ -56,9 +56,6 @@ #define CK_HT_PROBE_DEFAULT 64ULL #endif -#define CK_HT_KEY_EMPTY ((uintptr_t)0) -#define CK_HT_KEY_TOMBSTONE (~(uintptr_t)0) - struct ck_ht_map { enum ck_ht_mode mode; uint64_t deletions;