1
6
7
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
43
44
45
46
49
50
51
52
53
54
59
62
63
64
65
66
69
70
71
72
73
93
94
95
96
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/* ... */
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <multi_heap.h>
#include "multi_heap_internal.h"
#include "heap_private.h"
#include "esp_heap_task_info.h"6 includes
#ifdef CONFIG_HEAP_TASK_TRACKING
/* ... */
size_t heap_caps_get_per_task_info(heap_task_info_params_t *params)
{
heap_t *reg;
heap_task_block_t *blocks = params->blocks;
size_t count = *params->num_totals;
size_t remaining = params->max_blocks;
if (params->totals) {
for (size_t i = 0; i < count; ++i) {
for (size_t type = 0; type < NUM_HEAP_TASK_CAPS; ++type) {
params->totals[i].size[type] = 0;
params->totals[i].count[type] = 0;
}{...}
}{...}
}{...}
SLIST_FOREACH(reg, ®istered_heaps, next) {
multi_heap_handle_t heap = reg->heap;
if (heap == NULL) {
continue;
}{...}
uint32_t caps = get_all_caps(reg);
uint32_t type;
for (type = 0; type < NUM_HEAP_TASK_CAPS; ++type) {
if ((caps & params->mask[type]) == params->caps[type]) {
break;
}{...}
}{...}
if (type == NUM_HEAP_TASK_CAPS) {
continue;
}{...}
multi_heap_block_handle_t b = multi_heap_get_first_block(heap);
multi_heap_internal_lock(heap);
for ( ; b ; b = multi_heap_get_next_block(heap, b)) {
if (multi_heap_is_free(b)) {
continue;
}{...}
void *p = multi_heap_get_block_address(b);
size_t bsize = multi_heap_get_allocated_size(heap, p);
TaskHandle_t btask = MULTI_HEAP_GET_BLOCK_OWNER(p);
if (params->totals) {
size_t i;
for (i = 0; i < count; ++i) {
if (params->totals[i].task == btask) {
break;
}{...}
}{...}
if (i < count) {
params->totals[i].size[type] += bsize;
params->totals[i].count[type] += 1;
}{...}
else {
if (count < params->max_totals) {
params->totals[count].task = btask;
params->totals[count].size[type] = bsize;
params->totals[i].count[type] = 1;
++count;
}{...}
}{...}
}{...}
if (blocks && remaining > 0) {
if (params->tasks) {
size_t i;
for (i = 0; i < params->num_tasks; ++i) {
if (btask == params->tasks[i]) {
break;
}{...}
}{...}
if (i == params->num_tasks) {
continue;
}{...}
}{...}
blocks->task = btask;
blocks->address = p;
blocks->size = bsize;
++blocks;
--remaining;
}{...}
}{...}
multi_heap_internal_unlock(heap);
}{...}
*params->num_totals = count;
return params->max_blocks - remaining;
}{ ... }
/* ... */#endif