Skip to content

Commit 1b6933d

Browse files
committed
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 <[email protected]>
1 parent 21d3225 commit 1b6933d

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lib/os/heap-validate.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ bool sys_heap_validate(struct sys_heap *heap)
171171
}
172172

173173
struct z_heap_stress_rec {
174-
void *(*alloc)(void *arg, size_t bytes);
175-
void (*free)(void *arg, void *p);
174+
void *(*alloc_fn)(void *arg, size_t bytes);
175+
void (*free_fn)(void *arg, void *p);
176176
void *arg;
177177
size_t total_bytes;
178178
struct z_heap_stress_block *blocks;
@@ -265,17 +265,17 @@ static size_t rand_free_choice(struct z_heap_stress_rec *sr)
265265
* scratch array is used to store temporary state and should be sized
266266
* about half as large as the heap itself. Returns true on success.
267267
*/
268-
void sys_heap_stress(void *(*alloc)(void *arg, size_t bytes),
269-
void (*free)(void *arg, void *p),
268+
void sys_heap_stress(void *(*alloc_fn)(void *arg, size_t bytes),
269+
void (*free_fn)(void *arg, void *p),
270270
void *arg, size_t total_bytes,
271271
uint32_t op_count,
272272
void *scratch_mem, size_t scratch_bytes,
273273
int target_percent,
274274
struct z_heap_stress_result *result)
275275
{
276276
struct z_heap_stress_rec sr = {
277-
.alloc = alloc,
278-
.free = free,
277+
.alloc_fn = alloc_fn,
278+
.free_fn = free_fn,
279279
.arg = arg,
280280
.total_bytes = total_bytes,
281281
.blocks = scratch_mem,
@@ -288,7 +288,7 @@ void sys_heap_stress(void *(*alloc)(void *arg, size_t bytes),
288288
for (uint32_t i = 0; i < op_count; i++) {
289289
if (rand_alloc_choice(&sr)) {
290290
size_t sz = rand_alloc_size(&sr);
291-
void *p = sr.alloc(sr.arg, sz);
291+
void *p = sr.alloc_fn(sr.arg, sz);
292292

293293
result->total_allocs++;
294294
if (p != NULL) {
@@ -307,7 +307,7 @@ void sys_heap_stress(void *(*alloc)(void *arg, size_t bytes),
307307
sr.blocks[b] = sr.blocks[sr.blocks_alloced - 1];
308308
sr.blocks_alloced--;
309309
sr.bytes_alloced -= sz;
310-
sr.free(sr.arg, p);
310+
sr.free_fn(sr.arg, p);
311311
}
312312
result->accumulated_in_use_bytes += sr.bytes_alloced;
313313
}

0 commit comments

Comments
 (0)