From 96538469ddeacfc65224f93bfc7736625e10321f Mon Sep 17 00:00:00 2001 From: Al Date: Thu, 23 Jul 2015 15:57:12 -0400 Subject: [PATCH] [utils] Adding a cstring_array_foreach macro --- src/string_utils.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/string_utils.h b/src/string_utils.h index 5aa1ea87..9dd54553 100644 --- a/src/string_utils.h +++ b/src/string_utils.h @@ -157,6 +157,13 @@ int64_t cstring_array_token_length(cstring_array *self, uint32_t i); void cstring_array_destroy(cstring_array *self); +#define cstring_array_foreach(array, s, code) { \ + for (int __si = 0; __si < array->indices->n; __si++) { \ + (s) = array->str->a + array->indices->a[__si]; \ + code; \ + } \ +} + /* String trees are a way of storing alternative representations of a tokenized string concisely