mark got_pathset iteration functions as safe
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
diff --git a/lib/got_lib_pathset.h b/lib/got_lib_pathset.h
index 2eb5498..098dd95 100644
--- a/lib/got_lib_pathset.h
+++ b/lib/got_lib_pathset.h
@@ -25,10 +25,10 @@ void *got_pathset_get(struct got_pathset *, const char *);
const struct got_error *got_pathset_remove(void **, struct got_pathset *,
const char *);
int got_pathset_contains(struct got_pathset *, const char *);
-const struct got_error *got_pathset_for_each(struct got_pathset *,
+const struct got_error *got_pathset_for_each_safe(struct got_pathset *,
const struct got_error *(*cb)(const char *, void *, void *),
void *);
-const struct got_error *got_pathset_for_each_reverse(struct got_pathset *,
+const struct got_error *got_pathset_for_each_reverse_safe(struct got_pathset *,
const struct got_error *(*cb)(const char *, void *, void *),
void *);
int got_pathset_num_elements(struct got_pathset *);
diff --git a/lib/pathset.c b/lib/pathset.c
index 66676de..828ea4b 100644
--- a/lib/pathset.c
+++ b/lib/pathset.c
@@ -185,7 +185,7 @@ got_pathset_contains(struct got_pathset *set, const char *path)
}
const struct got_error *
-got_pathset_for_each(struct got_pathset *set,
+got_pathset_for_each_safe(struct got_pathset *set,
const struct got_error *(*cb)(const char *, void *, void *), void *arg)
{
const struct got_error *err;
@@ -200,7 +200,7 @@ got_pathset_for_each(struct got_pathset *set,
}
const struct got_error *
-got_pathset_for_each_reverse(struct got_pathset *set,
+got_pathset_for_each_reverse_safe(struct got_pathset *set,
const struct got_error *(*cb)(const char *, void *, void *), void *arg)
{
const struct got_error *err;
diff --git a/lib/worktree.c b/lib/worktree.c
index 7678188..56b3803 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -862,7 +862,8 @@ remove_missing_files(struct got_worktree *worktree, const char *path,
a2.cancel_arg = cancel_arg;
a2.progress_cb = progress_cb;
a2.progress_arg = progress_arg;
- err = got_pathset_for_each(a.missing_entries, remove_missing_file, &a2);
+ err = got_pathset_for_each_safe(a.missing_entries, remove_missing_file,
+ &a2);
got_pathset_free(a.missing_entries);
return err;
}
diff --git a/regress/pathset/pathset_test.c b/regress/pathset/pathset_test.c
index 55c5c62..9cd8b5a 100644
--- a/regress/pathset/pathset_test.c
+++ b/regress/pathset/pathset_test.c
@@ -124,7 +124,7 @@ pathset_add_remove_iter(void)
goto done;
}
- got_pathset_for_each(set, pathset_add_remove_iter_cb, NULL);
+ got_pathset_for_each_safe(set, pathset_add_remove_iter_cb, NULL);
done:
got_pathset_free(set);
return (err == NULL);
@@ -213,9 +213,9 @@ pathset_iter_order(void)
goto done;
test_printf("normal order:\n");
- got_pathset_for_each(set, pathset_iter_order_cb, NULL);
+ got_pathset_for_each_safe(set, pathset_iter_order_cb, NULL);
test_printf("reverse order:\n");
- got_pathset_for_each_reverse(set, pathset_iter_reverse_order_cb,
+ got_pathset_for_each_reverse_safe(set, pathset_iter_reverse_order_cb,
NULL);
done:
got_pathset_free(set);