1 /*
2  * Copyright (c) 2019,2023 Intel Corporation
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 #include <zephyr/sys/sys_heap.h>
7 #include <zephyr/sys/util.h>
8 #include <zephyr/kernel.h>
9 #include "heap.h"
10 
sys_heap_runtime_stats_get(struct sys_heap * heap,struct sys_memory_stats * stats)11 int sys_heap_runtime_stats_get(struct sys_heap *heap,
12 		struct sys_memory_stats *stats)
13 {
14 	if ((heap == NULL) || (stats == NULL)) {
15 		return -EINVAL;
16 	}
17 
18 	stats->free_bytes = heap->heap->free_bytes;
19 	stats->allocated_bytes = heap->heap->allocated_bytes;
20 	stats->max_allocated_bytes = heap->heap->max_allocated_bytes;
21 
22 	return 0;
23 }
24 
sys_heap_runtime_stats_reset_max(struct sys_heap * heap)25 int sys_heap_runtime_stats_reset_max(struct sys_heap *heap)
26 {
27 	if (heap == NULL) {
28 		return -EINVAL;
29 	}
30 
31 	heap->heap->max_allocated_bytes = heap->heap->allocated_bytes;
32 
33 	return 0;
34 }
35