From 100c5f3b0b27ec6617de1a785c4ff481e92636c1 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Mon, 16 Apr 2007 22:11:43 -0700 Subject: 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 Signed-off-by: Junio C Hamano --- object.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'object.c') diff --git a/object.c b/object.c index 153ebac66d..7bd3fec556 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; } -- cgit v1.2.3