Imported Upstream version 2.0.2
[platform/upstream/git.git] / alloc.c
diff --git a/alloc.c b/alloc.c
index f3ee745..eb22a45 100644 (file)
--- a/alloc.c
+++ b/alloc.c
@@ -47,23 +47,32 @@ union any_object {
 
 DEFINE_ALLOCATOR(blob, struct blob)
 DEFINE_ALLOCATOR(tree, struct tree)
-DEFINE_ALLOCATOR(commit, struct commit)
+DEFINE_ALLOCATOR(raw_commit, struct commit)
 DEFINE_ALLOCATOR(tag, struct tag)
 DEFINE_ALLOCATOR(object, union any_object)
 
+void *alloc_commit_node(void)
+{
+       static int commit_count;
+       struct commit *c = alloc_raw_commit_node();
+       c->index = commit_count++;
+       return c;
+}
+
 static void report(const char *name, unsigned int count, size_t size)
 {
        fprintf(stderr, "%10s: %8u (%"PRIuMAX" kB)\n",
                        name, count, (uintmax_t) size);
 }
 
-#define REPORT(name)   \
-    report(#name, name##_allocs, name##_allocs * sizeof(struct name) >> 10)
+#define REPORT(name, type)     \
+    report(#name, name##_allocs, name##_allocs * sizeof(type) >> 10)
 
 void alloc_report(void)
 {
-       REPORT(blob);
-       REPORT(tree);
-       REPORT(commit);
-       REPORT(tag);
+       REPORT(blob, struct blob);
+       REPORT(tree, struct tree);
+       REPORT(raw_commit, struct commit);
+       REPORT(tag, struct tag);
+       REPORT(object, union any_object);
 }