From: Ben Pfaff Date: Wed, 24 Jun 2009 17:21:39 +0000 (-0700) Subject: shash: New function shash_first(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7efc68eb075acfe3c00fbe1a8ed2146c445f1139;p=openvswitch shash: New function shash_first(). --- 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 */