autoconf: Checks for some library functions.
[gitweb.git] / object.c
index e26e319ccd22e5c9e9125e58f9ed32620afd66b1..31c77ea03a2083ce9ed7c71a2b4d90fb6b944c78 100644 (file)
--- a/object.c
+++ b/object.c
@@ -5,9 +5,18 @@
 #include "commit.h"
 #include "tag.h"
 
-struct object **objs;
-static int nr_objs;
-int obj_allocs;
+static struct object **objs;
+static int nr_objs, obj_allocs;
+
+unsigned int get_max_object_index(void)
+{
+       return obj_allocs;
+}
+
+struct object *get_indexed_object(unsigned int idx)
+{
+       return objs[idx];
+}
 
 const char *type_names[] = {
        "none", "blob", "tree", "commit", "bad"
@@ -200,3 +209,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;
+}