From 84a25ec83e75ac18c2ede0e89c2748c16604f364 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Thu, 11 Apr 2019 00:49:45 -0400 Subject: [PATCH] fix build with CONFIG_STATS enabled --- h_malloc.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/h_malloc.c b/h_malloc.c index 0f887d8..507088c 100644 --- a/h_malloc.c +++ b/h_malloc.c @@ -448,43 +448,31 @@ static u64 get_random_canary(struct random_state *rng) { } static inline void stats_small_allocate(UNUSED struct size_class *c, UNUSED size_t size) { -#if STATS +#if CONFIG_STATS c->allocated += size; c->nmalloc++; #endif } static inline void stats_small_deallocate(UNUSED struct size_class *c, UNUSED size_t size) { -#if STATS +#if CONFIG_STATS c->allocated -= size; c->ndalloc++; #endif } static inline void stats_slab_allocate(UNUSED struct size_class *c, UNUSED size_t slab_size) { -#if STATS +#if CONFIG_STATS c->slab_allocated += slab_size; #endif } -static inline void stats_slab_deallocate(UNUSED struct size_class *c, UNUSED size_t size) { -#if STATS +static inline void stats_slab_deallocate(UNUSED struct size_class *c, UNUSED size_t slab_size) { +#if CONFIG_STATS c->slab_allocated -= slab_size; #endif } -static inline void stats_large_allocate(UNUSED struct region_allocator *ra, UNUSED size_t size) { -#if STATS - ra->allocated += size; -#endif -} - -static inline void stats_large_deallocate(UNUSED struct region_allocator *ra, UNUSED size_t size) { -#if STATS - ra->allocated -= size; -#endif -} - static inline void *allocate_small(size_t requested_size) { struct size_info info = get_size_info(requested_size); size_t size = info.size ? info.size : 16; @@ -801,6 +789,18 @@ struct region_allocator { struct random_state rng; }; +static inline void stats_large_allocate(UNUSED struct region_allocator *ra, UNUSED size_t size) { +#if CONFIG_STATS + ra->allocated += size; +#endif +} + +static inline void stats_large_deallocate(UNUSED struct region_allocator *ra, UNUSED size_t size) { +#if CONFIG_STATS + ra->allocated -= size; +#endif +} + struct __attribute__((aligned(PAGE_SIZE))) slab_info_mapping { struct slab_metadata slab_info[MAX_METADATA_MAX]; };