X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fhmap.h;h=c78dddaca95977a87ca7c16c0adb4653d515aff4;hb=70feacd5320c141c6f81d9557c0e608326b4d169;hp=5396c79b60cb2f3cbcea00a7cf37c92aa181934d;hpb=3adb8bf04838d8fa5a382f501437b62af99ed874;p=openvswitch diff --git a/lib/hmap.h b/lib/hmap.h index 5396c79b..c78dddac 100644 --- a/lib/hmap.h +++ b/lib/hmap.h @@ -33,6 +33,24 @@ static inline size_t hmap_node_hash(const struct hmap_node *node) return node->hash; } +#define HMAP_NODE_NULL ((struct hmap_node *) 1) + +/* Returns true if 'node' has been set to null by hmap_node_nullify() and has + * not been un-nullified by being inserted into an hmap. */ +static inline bool +hmap_node_is_null(const struct hmap_node *node) +{ + return node->next == HMAP_NODE_NULL; +} + +/* Marks 'node' with a distinctive value that can be tested with + * hmap_node_is_null(). */ +static inline void +hmap_node_nullify(struct hmap_node *node) +{ + node->next = HMAP_NODE_NULL; +} + /* A hash map. */ struct hmap { struct hmap_node **buckets;