directory rename detection: directory splitting testcases
[gitweb.git] / object.c
index 06ba3a11d87ad7b93f29aef535e773fcc4683004..b9a4a0e50172fb169226786b17134c6ab0627333 100644 (file)
--- a/object.c
+++ b/object.c
@@ -141,7 +141,6 @@ void *create_object(const unsigned char *sha1, void *o)
        struct object *obj = o;
 
        obj->parsed = 0;
-       obj->used = 0;
        obj->flags = 0;
        hashcpy(obj->oid.hash, sha1);
 
@@ -354,6 +353,19 @@ static void object_array_release_entry(struct object_array_entry *ent)
        free(ent->path);
 }
 
+struct object *object_array_pop(struct object_array *array)
+{
+       struct object *ret;
+
+       if (!array->nr)
+               return NULL;
+
+       ret = array->objects[array->nr - 1].item;
+       object_array_release_entry(&array->objects[array->nr - 1]);
+       array->nr--;
+       return ret;
+}
+
 void object_array_filter(struct object_array *array,
                         object_array_each_func_t want, void *cb_data)
 {
@@ -377,8 +389,7 @@ void object_array_clear(struct object_array *array)
        int i;
        for (i = 0; i < array->nr; i++)
                object_array_release_entry(&array->objects[i]);
-       free(array->objects);
-       array->objects = NULL;
+       FREE_AND_NULL(array->objects);
        array->nr = array->alloc = 0;
 }