---
 lib/sset.c |   20 ++++++++++++++++++++
 lib/sset.h |    1 +
 2 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/lib/sset.c b/lib/sset.c
index 9a0936b..7a8f5b6 100644
--- a/lib/sset.c
+++ b/lib/sset.c
@@ -161,6 +161,26 @@ sset_add_array(struct sset *set, char **names, size_t n)
     }
 }
 
+/* Populates 'names' with at most 'n' strings in 'set'.  'set' retains
+ * ownership of the populated strings.  Returns the number of strings written
+ * to 'names. */
+size_t
+sset_to_array(struct sset *set, char **names, size_t n)
+{
+    const char *name;
+    size_t i = 0;
+
+    SSET_FOR_EACH (name, set) {
+        if (i >= n) {
+            break;
+        }
+
+        names[i++] = (char *) name;
+    }
+
+    return i;
+}
+
 /* Removes all of the strings from 'set'. */
 void
 sset_clear(struct sset *set)
diff --git a/lib/sset.h b/lib/sset.h
index a739fce..987b394 100644
--- a/lib/sset.h
+++ b/lib/sset.h
@@ -51,6 +51,7 @@ struct sset_node *sset_add(struct sset *, const char *);
 struct sset_node *sset_add_and_free(struct sset *, char *);
 void sset_add_assert(struct sset *, const char *);
 void sset_add_array(struct sset *, char **, size_t n);
+size_t sset_to_array(struct sset *, char **, size_t n);
 
 /* Deletion. */
 void sset_clear(struct sset *);
-- 
1.7.6.1

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to