Skip to content

Commit

Permalink
lib/os: use generic mem stats structure for heap
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
peter-mitsis authored and fabiobaltieri committed Jul 12, 2022
1 parent d061366 commit 3b7818b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
9 changes: 2 additions & 7 deletions include/zephyr/sys/sys_heap.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <stddef.h>
#include <stdbool.h>
#include <zephyr/types.h>
#include <sys/mem_stats.h>

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -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
*
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions lib/os/heap-validate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 3b7818b

Please sign in to comment.