forked from zephyrproject-rtos/zephyr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib: heap: move heap stats to own file
heap stats are split out from heap_validate.c into own file. Signed-off-by: Anas Nashif <[email protected]>
- Loading branch information
Showing
3 changed files
with
35 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright (c) 2019,2023 Intel Corporation | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
#include <zephyr/sys/sys_heap.h> | ||
#include <zephyr/sys/util.h> | ||
#include <zephyr/kernel.h> | ||
#include "heap.h" | ||
|
||
int sys_heap_runtime_stats_get(struct sys_heap *heap, | ||
struct sys_memory_stats *stats) | ||
{ | ||
if ((heap == NULL) || (stats == NULL)) { | ||
return -EINVAL; | ||
} | ||
|
||
stats->free_bytes = heap->heap->free_bytes; | ||
stats->allocated_bytes = heap->heap->allocated_bytes; | ||
stats->max_allocated_bytes = heap->heap->max_allocated_bytes; | ||
|
||
return 0; | ||
} | ||
|
||
int sys_heap_runtime_stats_reset_max(struct sys_heap *heap) | ||
{ | ||
if (heap == NULL) { | ||
return -EINVAL; | ||
} | ||
|
||
heap->heap->max_allocated_bytes = heap->heap->allocated_bytes; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters