From 3b7818b2d29e30b0a336c2182764aaa6a65e478c Mon Sep 17 00:00:00 2001 From: Peter Mitsis Date: Wed, 6 Jul 2022 10:19:30 -0400 Subject: [PATCH] lib/os: use generic mem stats structure for heap Since the retrieved heap memory statistics are identical to those of the retrieved mem_block statistics, it makes sense to use a single generic-named structure for both instead of two identical structures with different names. Signed-off-by: Peter Mitsis --- include/zephyr/sys/sys_heap.h | 9 ++------- lib/os/heap-validate.c | 4 ++-- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/include/zephyr/sys/sys_heap.h b/include/zephyr/sys/sys_heap.h index 27b192fa299..ebdb4f8e703 100644 --- a/include/zephyr/sys/sys_heap.h +++ b/include/zephyr/sys/sys_heap.h @@ -9,6 +9,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { @@ -67,12 +68,6 @@ struct z_heap_stress_result { #ifdef CONFIG_SYS_HEAP_RUNTIME_STATS -struct sys_heap_runtime_stats { - size_t free_bytes; - size_t allocated_bytes; - size_t max_allocated_bytes; -}; - /** * @brief Get the runtime statistics of a sys_heap * @@ -81,7 +76,7 @@ struct sys_heap_runtime_stats { * @return -EINVAL if null pointers, otherwise 0 */ int sys_heap_runtime_stats_get(struct sys_heap *heap, - struct sys_heap_runtime_stats *stats); + struct sys_memory_stats *stats); /** * @brief Reset the maximum heap usage. diff --git a/lib/os/heap-validate.c b/lib/os/heap-validate.c index 967b053e06e..18aafe71804 100644 --- a/lib/os/heap-validate.c +++ b/lib/os/heap-validate.c @@ -110,7 +110,7 @@ bool sys_heap_validate(struct sys_heap *heap) * sys_heap_runtime_stats_get function. */ size_t allocated_bytes, free_bytes; - struct sys_heap_runtime_stats stat; + struct sys_memory_stats stat; get_alloc_info(h, &allocated_bytes, &free_bytes); sys_heap_runtime_stats_get(heap, &stat); @@ -414,7 +414,7 @@ void sys_heap_print_info(struct sys_heap *heap, bool dump_chunks) #ifdef CONFIG_SYS_HEAP_RUNTIME_STATS int sys_heap_runtime_stats_get(struct sys_heap *heap, - struct sys_heap_runtime_stats *stats) + struct sys_memory_stats *stats) { if ((heap == NULL) || (stats == NULL)) { return -EINVAL;