summaryrefslogtreecommitdiff
path: root/object.c
diff options
context:
space:
mode:
Diffstat (limited to 'object.c')
-rw-r--r--object.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/object.c b/object.c
index 20703f52ed..fcd4a82c13 100644
--- a/object.c
+++ b/object.c
@@ -278,6 +278,22 @@ void add_object_array_with_mode(struct object *obj, const char *name, struct obj
array->nr = ++nr;
}
+void object_array_filter(struct object_array *array,
+ object_array_each_func_t want, void *cb_data)
+{
+ unsigned nr = array->nr, src, dst;
+ struct object_array_entry *objects = array->objects;
+
+ for (src = dst = 0; src < nr; src++) {
+ if (want(&objects[src], cb_data)) {
+ if (src != dst)
+ objects[dst] = objects[src];
+ dst++;
+ }
+ }
+ array->nr = dst;
+}
+
void object_array_remove_duplicates(struct object_array *array)
{
unsigned int ref, src, dst;