aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/util
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2017-02-09 08:00:31 -0800
committerGravatar Craig Tiller <ctiller@google.com>2017-02-09 08:00:31 -0800
commit44cc814bcafb470049f26de8e0a45ccc2c1a8c78 (patch)
tree8ac096ac229a22b95da8d9a345a8e7824d8a64c8 /test/core/util
parent3fd00c2ec7fc544962218ee12d0b1da064f271fb (diff)
Add lots of casts
Diffstat (limited to 'test/core/util')
-rw-r--r--test/core/util/memory_counters.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/test/core/util/memory_counters.c b/test/core/util/memory_counters.c
index 0a782b3470..fd6770bd49 100644
--- a/test/core/util/memory_counters.c
+++ b/test/core/util/memory_counters.c
@@ -49,10 +49,14 @@ static void guard_free(void *vptr);
static void *guard_malloc(size_t size) {
size_t *ptr;
if (!size) return NULL;
- gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_size_absolute, size);
- gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_size_relative, size);
- gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_allocs_absolute, 1);
- gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_allocs_relative, 1);
+ gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_size_absolute,
+ (gpr_atm)size);
+ gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_size_relative,
+ (gpr_atm)size);
+ gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_allocs_absolute,
+ (gpr_atm)1);
+ gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_allocs_relative,
+ (gpr_atm)1);
ptr = g_old_allocs.malloc_fn(size + sizeof(size));
*ptr++ = size;
return ptr;
@@ -68,10 +72,14 @@ static void *guard_realloc(void *vptr, size_t size) {
return NULL;
}
--ptr;
- gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_size_absolute, size);
- gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_size_relative, -*ptr);
- gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_size_relative, size);
- gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_allocs_absolute, 1);
+ gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_size_absolute,
+ (gpr_atm)size);
+ gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_size_relative,
+ -(gpr_atm)*ptr);
+ gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_size_relative,
+ (gpr_atm)size);
+ gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_allocs_absolute,
+ (gpr_atm)1);
ptr = g_old_allocs.realloc_fn(ptr, size + sizeof(size));
*ptr++ = size;
return ptr;
@@ -81,8 +89,10 @@ static void guard_free(void *vptr) {
size_t *ptr = vptr;
if (!vptr) return;
--ptr;
- gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_size_relative, -*ptr);
- gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_allocs_relative, -1);
+ gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_size_relative,
+ -(gpr_atm)*ptr);
+ gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_allocs_relative,
+ -(gpr_atm)1);
g_old_allocs.free_fn(ptr);
}