diff options
author | Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk> | 2006-07-30 16:38:28 +0100 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-08-02 00:27:18 -0700 |
commit | 579d1fbfaf25550254014fa472faac95f88eb779 (patch) | |
tree | a6cc7f0ba87e166d30007e6e9c91213a8ca7dded /alloc.c | |
parent | 446c6faec69f7ac521b8b9fc2b1874731729032f (diff) | |
download | git-579d1fbfaf25550254014fa472faac95f88eb779.tar.gz |
Add NO_C99_FORMAT to support older compilers.
The NO_C99_FORMAT macro allows compilers that lack support for the
ll,hh,j,z,t size specifiers (eg. gcc 2.95.2) to adapt the code to avoid
runtime errors in the formatted IO functions.
Signed-off-by: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'alloc.c')
-rw-r--r-- | alloc.c | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -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) { |