X-Git-Url: http://git.onelab.eu/?p=sliver-openvswitch.git;a=blobdiff_plain;f=lib%2Fhindex.h;h=631fd487d9079feb39ca7464699522a39c8ee236;hp=fb6b6d2bda0536e90efa632b9e0332a54ba2f4a0;hb=3d91d9094dcf49c210bd4ebae4bd1e0cea9defce;hpb=28a560d97a8b6882e7dfd4df2e52806dba4fd0e5 diff --git a/lib/hindex.h b/lib/hindex.h index fb6b6d2bd..631fd487d 100644 --- a/lib/hindex.h +++ b/lib/hindex.h @@ -132,7 +132,18 @@ void hindex_remove(struct hindex *, struct hindex_node *); NODE != OBJECT_CONTAINING(NULL, NODE, MEMBER); \ ASSIGN_CONTAINER(NODE, (NODE)->MEMBER.s, MEMBER)) -struct hindex_node *hindex_node_with_hash(const struct hindex *, size_t hash); +/* Returns the head node in 'hindex' with the given 'hash', or a null pointer + * if no nodes have that hash value. */ +static inline struct hindex_node * +hindex_node_with_hash(const struct hindex *hindex, size_t hash) +{ + struct hindex_node *node = hindex->buckets[hash & hindex->mask]; + + while (node && node->hash != hash) { + node = node->d; + } + return node; +} /* Iteration. */