diff options
author | Eric Wong <normalperson@yhbt.net> | 2008-10-07 22:07:29 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-10-07 22:07:29 +0200 |
commit | bb04c6342e692b39d04126940570a5ade9ca371a (patch) | |
tree | c2c5fbbcce69fbb6d53ee46d5c15587a8b88305a /src/songvec.c | |
parent | e19f6905d9c209d7587177dbfdbc58869a2167cc (diff) | |
download | mpd-bb04c6342e692b39d04126940570a5ade9ca371a.tar.gz mpd-bb04c6342e692b39d04126940570a5ade9ca371a.tar.xz mpd-bb04c6342e692b39d04126940570a5ade9ca371a.zip |
songvec: add songvec_for_each iterator
This is so we can more consistently deal with locking
needed for thread-safety in iterator functions.
Diffstat (limited to '')
-rw-r--r-- | src/songvec.c | 13 |
1 files changed, 13 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; +} |