path: root/object.c
diff options
authorLinus Torvalds <>2007-04-17 05:10:19 (GMT)
committerJunio C Hamano <>2007-04-17 06:36:11 (GMT)
commit2c1cbec1e2f0bd7b15fe5e921d287babfd91c7d3 (patch)
treeee149f21b7fe1a53ced6a4051e10268608d14d54 /object.c
parentf948792990f82a35bf0c98510e7511ef8acb9cd3 (diff)
Use proper object allocators for unknown object nodes too
We used to use a different allocator scheme for when we didn't know the object type. That meant that objects that were created without any up-front knowledge of the type would not go through the same allocation paths as normal object allocations, and would miss out on the statistics. But perhaps more importantly than the statistics (that are useful when looking at memory usage but not much else), if we want to make the object hash tables use a denser object pointer representation, we need to make sure that they all go through the same blocking allocator. Signed-off-by: Linus Torvalds <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'object.c')
1 files changed, 3 insertions, 12 deletions
diff --git a/object.c b/object.c
index 78a44a6..153ebac 100644
--- a/object.c
+++ b/object.c
@@ -120,22 +120,13 @@ void created_object(const unsigned char *sha1, struct object *obj)
-union any_object {
- struct object object;
- struct commit commit;
- struct tree tree;
- struct blob blob;
- struct tag tag;
struct object *lookup_unknown_object(const unsigned char *sha1)
struct object *obj = lookup_object(sha1);
if (!obj) {
- union any_object *ret = xcalloc(1, sizeof(*ret));
- created_object(sha1, &ret->object);
- ret->object.type = OBJ_NONE;
- return &ret->object;
+ obj = alloc_object_node();
+ created_object(sha1, obj);
+ obj->type = OBJ_NONE;
return obj;