add an extra callback argument to got_object_idset_for_each()
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
diff --git a/lib/got_lib_object_idset.h b/lib/got_lib_object_idset.h
index 1c726ce..ce9c832 100644
--- a/lib/got_lib_object_idset.h
+++ b/lib/got_lib_object_idset.h
@@ -27,5 +27,5 @@ const struct got_error *got_object_idset_remove(struct got_object_idset *,
int got_object_idset_contains(struct got_object_idset *,
struct got_object_id *);
void got_object_idset_for_each(struct got_object_idset *,
- void (*cb)(struct got_object_id *, void *));
+ void (*cb)(struct got_object_id *, void *, void *), void *);
unsigned int got_object_idset_num_elements(struct got_object_idset *);
diff --git a/lib/object_idset.c b/lib/object_idset.c
index 3487cfb..2fa47df 100644
--- a/lib/object_idset.c
+++ b/lib/object_idset.c
@@ -196,14 +196,14 @@ got_object_idset_contains(struct got_object_idset *set,
}
void got_object_idset_for_each(struct got_object_idset *set,
- void (*cb)(struct got_object_id *, void *))
+ void (*cb)(struct got_object_id *, void *, void *), void *arg)
{
struct got_object_idset_element *entry;
int i;
for (i = 0; i < nitems(set->entries); i++) {
TAILQ_FOREACH(entry, &set->entries[i], entry)
- cb(&entry->id, entry->data);
+ cb(&entry->id, entry->data, arg);
}
}
diff --git a/regress/idset/idset_test.c b/regress/idset/idset_test.c
index 78476ec..3b62000 100644
--- a/regress/idset/idset_test.c
+++ b/regress/idset/idset_test.c
@@ -56,7 +56,7 @@ static const char *data1 = "data1", *data2 = "data2", *data3 = "data3";
static int iter_count;
static void
-idset_cb(struct got_object_id *id, void *data) {
+idset_cb(struct got_object_id *id, void *data, void *arg) {
if (iter_count == 0 &&
(got_object_id_cmp(id, &id1) != 0 || data != (void *)data1))
abort();
@@ -182,7 +182,7 @@ idset_add_remove_iter(void)
goto done;
}
- got_object_idset_for_each(set, idset_cb);
+ got_object_idset_for_each(set, idset_cb, NULL);
done:
got_object_idset_free(set);
return (err == NULL);
diff --git a/tog/Makefile b/tog/Makefile
index cb1a8b9..730e0f0 100644
--- a/tog/Makefile
+++ b/tog/Makefile
@@ -3,7 +3,7 @@
PROG= tog
SRCS= tog.c delta.c diff.c diffreg.c error.c fileindex.c object.c \
opentemp.c path.c pack.c privsep.c reference.c repository.c \
- sha1.c worktree.c zbuf.c
+ sha1.c worktree.c zbuf.c object_idset.c commit_graph.c
CPPFLAGS = -I${.CURDIR}/../include -I${.CURDIR}/../lib
LDADD = -lpanel -lncursesw -lutil -lz