diff options
author | H. Peter Anvin (Intel) <hpa@zytor.com> | 2020-07-08 09:48:43 -0700 |
---|---|---|
committer | H. Peter Anvin (Intel) <hpa@zytor.com> | 2020-07-08 09:49:38 -0700 |
commit | 68e3802b238b964900acac9422a70e295482243f (patch) | |
tree | 31fe313828151dcc7f910082413c4e4a52fa6a49 /nasmlib | |
parent | c341ad7300afa3f71db5cd9813bbeebf32f9195b (diff) | |
download | nasm-master.tar.gz |
Sometimes we want to search for an exact key only, and reject the case
when tree->key < key. Add rb_search_exact() for this purpose, rather
than forcing the caller to perform the comparison in open code.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Diffstat (limited to 'nasmlib')
-rw-r--r-- | nasmlib/rbtree.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/nasmlib/rbtree.c b/nasmlib/rbtree.c index 510f34b1..773338bb 100644 --- a/nasmlib/rbtree.c +++ b/nasmlib/rbtree.c @@ -87,6 +87,14 @@ struct rbtree *rb_search(const struct rbtree *tree, uint64_t key) return (struct rbtree *)best; } +struct rbtree *rb_search_exact(const struct rbtree *tree, uint64_t key) +{ + struct rbtree *rv; + + rv = rb_search(tree, key); + return (rv && rv->key == key) ? rv : NULL; +} + /* Reds two left in a row? */ static inline bool is_red_left_left(struct rbtree *h) { |