X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=alloc.c;h=460db192d5a7de4073eb89972871720dd1c8fe1e;hb=1c2a4f5addce479c619057c6cdc841802139982f;hp=e3b22f43228cae90290150ad2a5c81ed97f337de;hpb=9e37f72afe49c133bfc54b17b659b2ae6f189b7f;p=git.git diff --git a/alloc.c b/alloc.c index e3b22f432..460db192d 100644 --- a/alloc.c +++ b/alloc.c @@ -39,8 +39,21 @@ DEFINE_ALLOCATOR(tree) DEFINE_ALLOCATOR(commit) DEFINE_ALLOCATOR(tag) +#ifdef NO_C99_FORMAT +#define SZ_FMT "%u" +#else +#define SZ_FMT "%zu" +#endif + +static void report(const char* name, unsigned int count, size_t size) +{ + fprintf(stderr, "%10s: %8u (" SZ_FMT " kB)\n", name, count, size); +} + +#undef SZ_FMT + #define REPORT(name) \ - fprintf(stderr, "%10s: %8u (%zu kB)\n", #name, name##_allocs, name##_allocs*sizeof(struct name) >> 10) + report(#name, name##_allocs, name##_allocs*sizeof(struct name) >> 10) void alloc_report(void) {