aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/songvec.c13
-rw-r--r--src/songvec.h2
2 files changed, 15 insertions, 0 deletions
diff --git a/src/songvec.c b/src/songvec.c
index 8e3b9b955..dd188f46c 100644
--- a/src/songvec.c
+++ b/src/songvec.c
@@ -66,3 +66,16 @@ void songvec_destroy(struct songvec *sv)
}
sv->nr = 0;
}
+
+int songvec_for_each(struct songvec *sv, int (*fn)(Song *, void *), void *arg)
+{
+ int i;
+ Song **sp = sv->base;
+
+ for (i = sv->nr; --i >= 0; ) {
+ if (fn(*sp++, arg) < 0)
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/src/songvec.h b/src/songvec.h
index 47b5ea6c0..dbe6be508 100644
--- a/src/songvec.h
+++ b/src/songvec.h
@@ -19,4 +19,6 @@ void songvec_add(struct songvec *sv, Song *add);
void songvec_destroy(struct songvec *sv);
+int songvec_for_each(struct songvec *sv, int (*fn)(Song *, void *), void *arg);
+
#endif /* SONGVEC_H */