From 1b6933d231156d4b880f486e60e63d194371476b Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Mon, 22 Mar 2021 08:01:59 -0400 Subject: [PATCH] kernel: heap: rename 'free' and 'alloc' This symbol is reserved and usage of reserved symbols violates the coding guidelines. (MISRA 21.2) Signed-off-by: Anas Nashif --- lib/os/heap-validate.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/os/heap-validate.c b/lib/os/heap-validate.c index e121dbb6bd7..f5b681c228a 100644 --- a/lib/os/heap-validate.c +++ b/lib/os/heap-validate.c @@ -171,8 +171,8 @@ bool sys_heap_validate(struct sys_heap *heap) } struct z_heap_stress_rec { - void *(*alloc)(void *arg, size_t bytes); - void (*free)(void *arg, void *p); + void *(*alloc_fn)(void *arg, size_t bytes); + void (*free_fn)(void *arg, void *p); void *arg; size_t total_bytes; struct z_heap_stress_block *blocks; @@ -265,8 +265,8 @@ static size_t rand_free_choice(struct z_heap_stress_rec *sr) * scratch array is used to store temporary state and should be sized * about half as large as the heap itself. Returns true on success. */ -void sys_heap_stress(void *(*alloc)(void *arg, size_t bytes), - void (*free)(void *arg, void *p), +void sys_heap_stress(void *(*alloc_fn)(void *arg, size_t bytes), + void (*free_fn)(void *arg, void *p), void *arg, size_t total_bytes, uint32_t op_count, void *scratch_mem, size_t scratch_bytes, @@ -274,8 +274,8 @@ void sys_heap_stress(void *(*alloc)(void *arg, size_t bytes), struct z_heap_stress_result *result) { struct z_heap_stress_rec sr = { - .alloc = alloc, - .free = free, + .alloc_fn = alloc_fn, + .free_fn = free_fn, .arg = arg, .total_bytes = total_bytes, .blocks = scratch_mem, @@ -288,7 +288,7 @@ void sys_heap_stress(void *(*alloc)(void *arg, size_t bytes), for (uint32_t i = 0; i < op_count; i++) { if (rand_alloc_choice(&sr)) { size_t sz = rand_alloc_size(&sr); - void *p = sr.alloc(sr.arg, sz); + void *p = sr.alloc_fn(sr.arg, sz); result->total_allocs++; if (p != NULL) { @@ -307,7 +307,7 @@ void sys_heap_stress(void *(*alloc)(void *arg, size_t bytes), sr.blocks[b] = sr.blocks[sr.blocks_alloced - 1]; sr.blocks_alloced--; sr.bytes_alloced -= sz; - sr.free(sr.arg, p); + sr.free_fn(sr.arg, p); } result->accumulated_in_use_bytes += sr.bytes_alloced; }