From 7efc68eb075acfe3c00fbe1a8ed2146c445f1139 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 24 Jun 2009 10:21:39 -0700 Subject: [PATCH] shash: New function shash_first(). --- lib/shash.c | 8 ++++++++ lib/shash.h | 1 + 2 files changed, 9 insertions(+) diff --git a/lib/shash.c b/lib/shash.c index 7f690843..93163727 100644 --- a/lib/shash.c +++ b/lib/shash.c @@ -97,3 +97,11 @@ shash_find_data(const struct shash *sh, const char *name) struct shash_node *node = shash_find(sh, name); return node ? node->data : NULL; } + +struct shash_node * +shash_first(const struct shash *shash) +{ + struct hmap_node *node = hmap_first(&shash->map); + return node ? CONTAINER_OF(node, struct shash_node, node) : NULL; +} + diff --git a/lib/shash.h b/lib/shash.h index 469e66e5..bcac41b5 100644 --- a/lib/shash.h +++ b/lib/shash.h @@ -39,5 +39,6 @@ void shash_add(struct shash *, const char *, void *); void shash_delete(struct shash *, struct shash_node *); struct shash_node *shash_find(const struct shash *, const char *); void *shash_find_data(const struct shash *, const char *); +struct shash_node *shash_first(const struct shash *); #endif /* shash.h */ -- 2.30.2