summaryrefslogtreecommitdiff
path: root/util/malloc-stats.c
diff options
context:
space:
mode:
authorRavi Nanjundappa <nravi.n@samsung.com>2014-04-23 08:32:19 +0530
committerBryce Harrington <b.harrington@samsung.com>2014-04-30 13:01:35 -0700
commit52b137bc3e3284ecef3102b0d976fd2320e0f473 (patch)
treeb1b2b389952d1cb9913610a3a18411046285fa1b /util/malloc-stats.c
parent0e0004a9716ca50bf14fa0e5e1919d90b8d11960 (diff)
downloadcairo-52b137bc3e3284ecef3102b0d976fd2320e0f473.tar.gz
test and util: maintain consistency in the usage of ARRAY_LENGTH macro
ARRAY_LENGTH macro is used in perf's cairo-perf.h, src's cairoint.h, test's cairo-test.h and in some internal header files of util's directory.So to maintain consistency ARRAY_SIZE is replaced with ARRAY_LENGTH macro. Signed-off-by: Ravi Nanjundappa <nravi.n@samsung.com> Reviewed-by: Bryce Harrington <b.harrington@samsung.com>
Diffstat (limited to 'util/malloc-stats.c')
-rw-r--r--util/malloc-stats.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/util/malloc-stats.c b/util/malloc-stats.c
index da91656dd..55ed51cad 100644
--- a/util/malloc-stats.c
+++ b/util/malloc-stats.c
@@ -60,8 +60,9 @@ static struct alloc_stats_t total_allocations;
static struct func_stat_t *func_stats[31627];
static int func_stats_num;
-#define ARRAY_SIZE(A) (sizeof (A)/sizeof (A[0]))
-
+#ifndef ARRAY_LENGTH
+#define ARRAY_LENGTH(__array) ((int) (sizeof (__array) / sizeof (__array[0])))
+#endif
static void
alloc_stats_add (struct alloc_stats_t *stats, int is_realloc, size_t size)
{
@@ -147,7 +148,7 @@ func_stats_add (const void *caller, int is_realloc, size_t size)
alloc_stats_add (&total_allocations, is_realloc, size);
- i = ((uintptr_t) caller ^ 1215497) % ARRAY_SIZE (func_stats);
+ i = ((uintptr_t) caller ^ 1215497) % ARRAY_LENGTH (func_stats);
for (elt = func_stats[i]; elt != NULL; elt = elt->next) {
if (elt->addr == caller)
break;
@@ -328,7 +329,7 @@ malloc_stats (void)
return;
j = 0;
- for (i = 0; i < ARRAY_SIZE (func_stats); i++) {
+ for (i = 0; i < ARRAY_LENGTH (func_stats); i++) {
struct func_stat_t *elt;
for (elt = func_stats[i]; elt != NULL; elt = elt->next)
sorted_func_stats[j++] = *elt;