Commit f2525e3e authored by Eric Wong's avatar Eric Wong Committed by Max Kellermann

dirvec: add dirvec_for_each iterator

This will make it easier to introduce locking
parent 1d385190
......@@ -78,3 +78,19 @@ void dirvec_destroy(struct dirvec *dv)
}
dv->nr = 0;
}
int dirvec_for_each(const struct dirvec *dv,
int (*fn)(struct directory *, void *), void *arg)
{
size_t i;
for (i = 0; i < dv->nr; ++i) {
struct directory *dir = dv->base[i];
assert(dir);
if (fn(dir, arg) < 0)
return -1;
}
return 0;
}
......@@ -24,4 +24,7 @@ dirvec_clear(struct dirvec *dv)
void dirvec_destroy(struct dirvec *dv);
int dirvec_for_each(const struct dirvec *dv,
int (*fn)(struct directory *, void *), void *arg);
#endif /* DIRVEC_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment