refactor: use _rpmalloc_stat_add64 for allocation counter (#233)
diff --git a/rpmalloc/rpmalloc.c b/rpmalloc/rpmalloc.c
index b02aba4..93a5931 100644
--- a/rpmalloc/rpmalloc.c
+++ b/rpmalloc/rpmalloc.c
@@ -2159,9 +2159,7 @@
//! Allocate a block of the given size
static void*
_rpmalloc_allocate(heap_t* heap, size_t size) {
-#if ENABLE_STATISTICS
- atomic_add64(&_allocation_counter, 1);
-#endif
+ _rpmalloc_stat_add64(&_allocation_counter, 1);
if (EXPECTED(size <= SMALL_SIZE_LIMIT))
return _rpmalloc_allocate_small(heap, size);
else if (size <= _memory_medium_size_limit)
@@ -2284,9 +2282,7 @@
#endif
++heap->full_span_count;
-#if ENABLE_STATISTICS
- atomic_add64(&_allocation_counter, 1);
-#endif
+ _rpmalloc_stat_add64(&_allocation_counter, 1);
return ptr;
}
@@ -2448,9 +2444,7 @@
//! Deallocate the given block
static void
_rpmalloc_deallocate(void* p) {
-#if ENABLE_STATISTICS
- atomic_add64(&_deallocation_counter, 1);
-#endif
+ _rpmalloc_stat_add64(&_deallocation_counter, 1);
//Grab the span (always at start of span, using span alignment)
span_t* span = (span_t*)((uintptr_t)p & _memory_span_mask);
if (UNEXPECTED(!span))