From: Ben Pfaff Date: Tue, 20 Jan 2009 21:34:02 +0000 (-0800) Subject: New function svec_join(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ec673f15786acbcedb724089c3a99420e83eea07;p=openvswitch New function svec_join(). --- diff --git a/lib/svec.c b/lib/svec.c index 728866b6..7f7e7594 100644 --- a/lib/svec.c +++ b/lib/svec.c @@ -321,3 +321,19 @@ svec_equal(const struct svec *a, const struct svec *b) } return true; } + +char * +svec_join(const struct svec *svec, const char *delimiter) +{ + struct ds ds; + size_t i; + + ds_init(&ds); + for (i = 0; i < svec->n; i++) { + if (i) { + ds_put_cstr(&ds, delimiter); + } + ds_put_cstr(&ds, svec->names[i]); + } + return ds_cstr(&ds); +} diff --git a/lib/svec.h b/lib/svec.h index 084d2e85..68d361c4 100644 --- a/lib/svec.h +++ b/lib/svec.h @@ -65,5 +65,6 @@ void svec_swap(struct svec *a, struct svec *b); void svec_print(const struct svec *svec, const char *title); void svec_parse_words(struct svec *svec, const char *words); bool svec_equal(const struct svec *, const struct svec *); +char *svec_join(const struct svec *, const char *delimiter); #endif /* svec.h */