summaryrefslogtreecommitdiff
path: root/object.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2007-04-17 05:11:43 (GMT)
committerJunio C Hamano <junkio@cox.net>2007-04-17 06:36:16 (GMT)
commit100c5f3b0b27ec6617de1a785c4ff481e92636c1 (patch)
tree365323d9a0483a9ca22b3a334a627cde1354d44e /object.c
parent2c1cbec1e2f0bd7b15fe5e921d287babfd91c7d3 (diff)
downloadgit-100c5f3b0b27ec6617de1a785c4ff481e92636c1.zip
git-100c5f3b0b27ec6617de1a785c4ff481e92636c1.tar.gz
git-100c5f3b0b27ec6617de1a785c4ff481e92636c1.tar.bz2
Clean up object creation to use more common code
This replaces the fairly odd "created_object()" function that did _most_ of the object setup with a more complete "create_object()" function that also has a more natural calling convention. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'object.c')
-rw-r--r--object.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/object.c b/object.c
index 153ebac..7bd3fec 100644
--- a/object.c
+++ b/object.c
@@ -105,11 +105,13 @@ static void grow_object_hash(void)
obj_hash_size = new_hash_size;
}
-void created_object(const unsigned char *sha1, struct object *obj)
+void *create_object(const unsigned char *sha1, int type, void *o)
{
+ struct object *obj = o;
+
obj->parsed = 0;
obj->used = 0;
- obj->type = OBJ_NONE;
+ obj->type = type;
obj->flags = 0;
hashcpy(obj->sha1, sha1);
@@ -118,16 +120,14 @@ void created_object(const unsigned char *sha1, struct object *obj)
insert_obj_hash(obj, obj_hash, obj_hash_size);
nr_objs++;
+ return obj;
}
struct object *lookup_unknown_object(const unsigned char *sha1)
{
struct object *obj = lookup_object(sha1);
- if (!obj) {
- obj = alloc_object_node();
- created_object(sha1, obj);
- obj->type = OBJ_NONE;
- }
+ if (!obj)
+ obj = create_object(sha1, OBJ_NONE, alloc_object_node());
return obj;
}