From 0273112b898ead0a86151fdf4543a0c52fef6e27 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 31 Dec 2008 14:33:47 -0800 Subject: [PATCH] New function svec_equal(). --- lib/svec.c | 16 ++++++++++++++++ lib/svec.h | 1 + 2 files changed, 17 insertions(+) diff --git a/lib/svec.c b/lib/svec.c index 054e5ffe..f0066392 100644 --- a/lib/svec.c +++ b/lib/svec.c @@ -277,3 +277,19 @@ svec_parse_words(struct svec *svec, const char *words) } ds_destroy(&word); } + +bool +svec_equal(const struct svec *a, const struct svec *b) +{ + size_t i; + + if (a->n != b->n) { + return false; + } + for (i = 0; i < a->n; i++) { + if (strcmp(a->names[i], b->names[i])) { + return false; + } + } + return true; +} diff --git a/lib/svec.h b/lib/svec.h index 2215c3cc..2ee275de 100644 --- a/lib/svec.h +++ b/lib/svec.h @@ -61,5 +61,6 @@ bool svec_is_sorted(const struct svec *); 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 *); #endif /* svec.h */ -- 2.30.2