X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=object.c;h=37784cee9a90a7e5b44dd660d6b7ea9191b59486;hb=e94528a0e99ea54520b8aff016275a7622c55a47;hp=e26e319ccd22e5c9e9125e58f9ed32620afd66b1;hpb=64e86c57867593ba0ee77a7b0ff0eb8e9d4d8ed5;p=git.git diff --git a/object.c b/object.c index e26e319cc..37784cee9 100644 --- a/object.c +++ b/object.c @@ -200,3 +200,20 @@ int object_list_contains(struct object_list *list, struct object *obj) } return 0; } + +void add_object_array(struct object *obj, const char *name, struct object_array *array) +{ + unsigned nr = array->nr; + unsigned alloc = array->alloc; + struct object_array_entry *objects = array->objects; + + if (nr >= alloc) { + alloc = (alloc + 32) * 2; + objects = xrealloc(objects, alloc * sizeof(*objects)); + array->alloc = alloc; + array->objects = objects; + } + objects[nr].item = obj; + objects[nr].name = name; + array->nr = ++nr; +}