| 401 | }; |
| 402 | |
| 403 | struct ref_iterator *prefix_ref_iterator_begin(struct ref_iterator *iter0, |
| 404 | const char *prefix, |
| 405 | int trim) |
| 406 | { |
| 407 | struct prefix_ref_iterator *iter; |
| 408 | struct ref_iterator *ref_iterator; |
| 409 | |
| 410 | if (!*prefix && !trim) |
| 411 | return iter0; /* optimization: no need to wrap iterator */ |
| 412 | |
| 413 | CALLOC_ARRAY(iter, 1); |
| 414 | ref_iterator = &iter->base; |
| 415 | |
| 416 | base_ref_iterator_init(ref_iterator, &prefix_ref_iterator_vtable); |
| 417 | |
| 418 | iter->iter0 = iter0; |
| 419 | iter->prefix = xstrdup(prefix); |
| 420 | iter->trim = trim; |
| 421 | |
| 422 | return ref_iterator; |
| 423 | } |
| 424 | |
| 425 | int do_for_each_ref_iterator(struct ref_iterator *iter, |
| 426 | refs_for_each_cb fn, void *cb_data) |
no test coverage detected