void *alloc_blob_node(void)
{
struct blob *b = alloc_node(&blob_state, sizeof(struct blob));
+ b->object.type = OBJ_BLOB;
return b;
}
void *alloc_tree_node(void)
{
struct tree *t = alloc_node(&tree_state, sizeof(struct tree));
+ t->object.type = OBJ_TREE;
return t;
}
void *alloc_tag_node(void)
{
struct tag *t = alloc_node(&tag_state, sizeof(struct tag));
+ t->object.type = OBJ_TAG;
return t;
}
void *alloc_object_node(void)
{
struct object *obj = alloc_node(&object_state, sizeof(union any_object));
+ obj->type = OBJ_NONE;
return obj;
}
static struct alloc_state commit_state;
+unsigned int alloc_commit_index(void)
+{
+ static unsigned int count;
+ return count++;
+}
+
void *alloc_commit_node(void)
{
- static int commit_count;
struct commit *c = alloc_node(&commit_state, sizeof(struct commit));
- c->index = commit_count++;
+ c->object.type = OBJ_COMMIT;
+ c->index = alloc_commit_index();
return c;
}