<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -20,7 +20,7 @@
 
 #define DEFINE_ALLOCATOR(name, type)				\
 static unsigned int name##_allocs;				\
-struct name *alloc_##name##_node(void)				\
+void *alloc_##name##_node(void)					\
 {								\
 	static int nr;						\
 	static type *block;					\</diff>
      <filename>alloc.c</filename>
    </modified>
    <modified>
      <diff>@@ -6,12 +6,8 @@ const char *blob_type = &quot;blob&quot;;
 struct blob *lookup_blob(const unsigned char *sha1)
 {
 	struct object *obj = lookup_object(sha1);
-	if (!obj) {
-		struct blob *ret = alloc_blob_node();
-		created_object(sha1, &amp;ret-&gt;object);
-		ret-&gt;object.type = OBJ_BLOB;
-		return ret;
-	}
+	if (!obj)
+		return create_object(sha1, OBJ_BLOB, alloc_blob_node());
 	if (!obj-&gt;type)
 		obj-&gt;type = OBJ_BLOB;
 	if (obj-&gt;type != OBJ_BLOB) {</diff>
      <filename>blob.c</filename>
    </modified>
    <modified>
      <diff>@@ -476,15 +476,11 @@ int decode_85(char *dst, const char *line, int linelen);
 void encode_85(char *buf, const unsigned char *data, int bytes);
 
 /* alloc.c */
-struct blob;
-struct tree;
-struct commit;
-struct tag;
-extern struct blob *alloc_blob_node(void);
-extern struct tree *alloc_tree_node(void);
-extern struct commit *alloc_commit_node(void);
-extern struct tag *alloc_tag_node(void);
-extern struct object *alloc_object_node(void);
+extern void *alloc_blob_node(void);
+extern void *alloc_tree_node(void);
+extern void *alloc_commit_node(void);
+extern void *alloc_tag_node(void);
+extern void *alloc_object_node(void);
 extern void alloc_report(void);
 
 /* trace.c */</diff>
      <filename>cache.h</filename>
    </modified>
    <modified>
      <diff>@@ -98,12 +98,8 @@ struct commit *lookup_commit_reference(const unsigned char *sha1)
 struct commit *lookup_commit(const unsigned char *sha1)
 {
 	struct object *obj = lookup_object(sha1);
-	if (!obj) {
-		struct commit *ret = alloc_commit_node();
-		created_object(sha1, &amp;ret-&gt;object);
-		ret-&gt;object.type = OBJ_COMMIT;
-		return ret;
-	}
+	if (!obj)
+		return create_object(sha1, OBJ_COMMIT, alloc_commit_node());
 	if (!obj-&gt;type)
 		obj-&gt;type = OBJ_COMMIT;
 	return check_commit(obj, sha1, 0);</diff>
      <filename>commit.c</filename>
    </modified>
    <modified>
      <diff>@@ -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-&gt;parsed = 0;
 	obj-&gt;used = 0;
-	obj-&gt;type = OBJ_NONE;
+	obj-&gt;type = type;
 	obj-&gt;flags = 0;
 	hashcpy(obj-&gt;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-&gt;type = OBJ_NONE;
-	}
+	if (!obj)
+		obj = create_object(sha1, OBJ_NONE, alloc_object_node());
 	return obj;
 }
 </diff>
      <filename>object.c</filename>
    </modified>
    <modified>
      <diff>@@ -46,7 +46,7 @@ extern struct object_refs *lookup_object_refs(struct object *);
 /** Internal only **/
 struct object *lookup_object(const unsigned char *sha1);
 
-void created_object(const unsigned char *sha1, struct object *obj);
+extern void *create_object(const unsigned char *sha1, int type, void *obj);
 
 /** Returns the object, having parsed it to find out what it is. **/
 struct object *parse_object(const unsigned char *sha1);</diff>
      <filename>object.h</filename>
    </modified>
    <modified>
      <diff>@@ -20,13 +20,9 @@ struct object *deref_tag(struct object *o, const char *warn, int warnlen)
 
 struct tag *lookup_tag(const unsigned char *sha1)
 {
-        struct object *obj = lookup_object(sha1);
-        if (!obj) {
-                struct tag *ret = alloc_tag_node();
-                created_object(sha1, &amp;ret-&gt;object);
-                ret-&gt;object.type = OBJ_TAG;
-                return ret;
-        }
+	struct object *obj = lookup_object(sha1);
+	if (!obj)
+		return create_object(sha1, OBJ_TAG, alloc_tag_node());
 	if (!obj-&gt;type)
 		obj-&gt;type = OBJ_TAG;
         if (obj-&gt;type != OBJ_TAG) {</diff>
      <filename>tag.c</filename>
    </modified>
    <modified>
      <diff>@@ -127,12 +127,8 @@ int read_tree(struct tree *tree, int stage, const char **match)
 struct tree *lookup_tree(const unsigned char *sha1)
 {
 	struct object *obj = lookup_object(sha1);
-	if (!obj) {
-		struct tree *ret = alloc_tree_node();
-		created_object(sha1, &amp;ret-&gt;object);
-		ret-&gt;object.type = OBJ_TREE;
-		return ret;
-	}
+	if (!obj)
+		return create_object(sha1, OBJ_TREE, alloc_tree_node());
 	if (!obj-&gt;type)
 		obj-&gt;type = OBJ_TREE;
 	if (obj-&gt;type != OBJ_TREE) {</diff>
      <filename>tree.c</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>2c1cbec1e2f0bd7b15fe5e921d287babfd91c7d3</id>
    </parent>
  </parents>
  <author>
    <name>Linus Torvalds</name>
    <email>torvalds@linux-foundation.org</email>
  </author>
  <url>http://github.com/schacon/git-source/commit/100c5f3b0b27ec6617de1a785c4ff481e92636c1</url>
  <id>100c5f3b0b27ec6617de1a785c4ff481e92636c1</id>
  <committed-date>2007-04-16T23:36:16-07:00</committed-date>
  <authored-date>2007-04-16T22:11:43-07:00</authored-date>
  <message>Clean up object creation to use more common code

This replaces the fairly odd &quot;created_object()&quot; function that did _most_
of the object setup with a more complete &quot;create_object()&quot; function that
also has a more natural calling convention.

Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Junio C Hamano &lt;junkio@cox.net&gt;</message>
  <tree>365323d9a0483a9ca22b3a334a627cde1354d44e</tree>
  <committer>
    <name>Junio C Hamano</name>
    <email>junkio@cox.net</email>
  </committer>
</commit>
