Select one of the symbols to view example projects that use it.
 
Outline
#include "freertos/FreeRTOS.h"
#include "sdkconfig.h"
#include "esp_rom_sys.h"
#include <assert.h>
multi_heap_lock_t
#define MULTI_HEAP_LOCK_STATIC_INITIALIZER
#define MULTI_HEAP_PRINTF
#define MULTI_HEAP_STDERR_PRINTF
multi_heap_assert(bool, const char *, int, intptr_t)
#include <freertos/task.h>
#define MULTI_HEAP_SET_BLOCK_OWNER
#define MULTI_HEAP_GET_BLOCK_OWNER
#define MULTI_HEAP_ADD_BLOCK_OWNER_OFFSET
#define MULTI_HEAP_REMOVE_BLOCK_OWNER_OFFSET
#define MULTI_HEAP_ADD_BLOCK_OWNER_SIZE
#define MULTI_HEAP_REMOVE_BLOCK_OWNER_SIZE
#define MULTI_HEAP_BLOCK_OWNER_SIZE
#define MULTI_HEAP_SET_BLOCK_OWNER
#define MULTI_HEAP_GET_BLOCK_OWNER
#define MULTI_HEAP_ADD_BLOCK_OWNER_OFFSET
#define MULTI_HEAP_REMOVE_BLOCK_OWNER_OFFSET
#define MULTI_HEAP_ADD_BLOCK_OWNER_SIZE
#define MULTI_HEAP_REMOVE_BLOCK_OWNER_SIZE
#define MULTI_HEAP_BLOCK_OWNER_SIZE
#include <assert.h>
#define MULTI_HEAP_PRINTF
#define MULTI_HEAP_STDERR_PRINTF
#define MULTI_HEAP_LOCK
#define MULTI_HEAP_UNLOCK
#define MULTI_HEAP_LOCK_INIT
#define MULTI_HEAP_LOCK_STATIC_INITIALIZER
#define MULTI_HEAP_ASSERT
#define MULTI_HEAP_BLOCK_OWNER
#define MULTI_HEAP_SET_BLOCK_OWNER
#define MULTI_HEAP_GET_BLOCK_OWNER
Files
loading (4/5)...
SourceVuESP-IDF Framework and ExamplesESP-IDFcomponents/heap/multi_heap_platform.h
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/* * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 *//* ... */ #pragma once #ifdef MULTI_HEAP_FREERTOS #include "freertos/FreeRTOS.h" #include "sdkconfig.h" #include "esp_rom_sys.h" #include <assert.h> typedef portMUX_TYPE multi_heap_lock_t; /* Because malloc/free can happen inside an ISR context, we need to use portmux spinlocks here not RTOS mutexes *//* ... */ #define MULTI_HEAP_LOCK(PLOCK) do { \ if((PLOCK) != NULL) { \ portENTER_CRITICAL_SAFE((PLOCK)); \ }{...} \ }{...} while(0)... #define MULTI_HEAP_UNLOCK(PLOCK) do { \ if ((PLOCK) != NULL) { \ portEXIT_CRITICAL_SAFE((PLOCK)); \ }{...} \ }{...} while(0)... #define MULTI_HEAP_LOCK_INIT(PLOCK) do { \ portMUX_INITIALIZE((PLOCK)); \ }{...} while(0)... #define MULTI_HEAP_LOCK_STATIC_INITIALIZER portMUX_INITIALIZER_UNLOCKED /* Not safe to use std i/o while in a portmux critical section, can deadlock, so we use the ROM equivalent functions. *//* ... */ #define MULTI_HEAP_PRINTF esp_rom_printf #define MULTI_HEAP_STDERR_PRINTF(MSG, ...) esp_rom_printf(MSG, __VA_ARGS__)6 defines inline static void multi_heap_assert(bool condition, const char *format, int line, intptr_t address) { /* Can't use libc assert() here as it calls printf() which can cause another malloc() for a newlib lock. Also, it's useful to be able to print the memory address where corruption was detected. *//* ... */ #ifndef NDEBUG if(!condition) { #ifndef CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT esp_rom_printf(format, line, address); #endif // CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT abort(); }{...} #else/* ... */ // NDEBUG (void) condition; #endif // NDEBUG }{ ... } #define MULTI_HEAP_ASSERT(CONDITION, ADDRESS) \ multi_heap_assert((CONDITION), "CORRUPT HEAP: multi_heap.c:%d detected at 0x%08x\n", \ __LINE__, (intptr_t)(ADDRESS))... #ifdef CONFIG_HEAP_TASK_TRACKING #include <freertos/task.h> #define MULTI_HEAP_SET_BLOCK_OWNER(HEAD) *((TaskHandle_t*)HEAD) = xTaskGetCurrentTaskHandle() #define MULTI_HEAP_GET_BLOCK_OWNER(HEAD) *((TaskHandle_t*)HEAD) #define MULTI_HEAP_ADD_BLOCK_OWNER_OFFSET(HEAD) ((TaskHandle_t*)(HEAD) + 1) #define MULTI_HEAP_REMOVE_BLOCK_OWNER_OFFSET(HEAD) ((TaskHandle_t*)(HEAD) - 1) #define MULTI_HEAP_ADD_BLOCK_OWNER_SIZE(SIZE) ((SIZE) + sizeof(TaskHandle_t)) #define MULTI_HEAP_REMOVE_BLOCK_OWNER_SIZE(SIZE) ((SIZE) - sizeof(TaskHandle_t)) #define MULTI_HEAP_BLOCK_OWNER_SIZE() sizeof(TaskHandle_t)7 defines /* ... */#else #define MULTI_HEAP_SET_BLOCK_OWNER(HEAD) #define MULTI_HEAP_GET_BLOCK_OWNER(HEAD) (NULL) #define MULTI_HEAP_ADD_BLOCK_OWNER_OFFSET(HEAD) (HEAD) #define MULTI_HEAP_REMOVE_BLOCK_OWNER_OFFSET(HEAD) (HEAD) #define MULTI_HEAP_ADD_BLOCK_OWNER_SIZE(SIZE) (SIZE) #define MULTI_HEAP_REMOVE_BLOCK_OWNER_SIZE(SIZE) (SIZE) #define MULTI_HEAP_BLOCK_OWNER_SIZE() 0/* ... */ #endif // CONFIG_HEAP_TASK_TRACKING /* ... */ #else // MULTI_HEAP_FREERTOS #include <assert.h> #define MULTI_HEAP_PRINTF printf #define MULTI_HEAP_STDERR_PRINTF(MSG, ...) fprintf(stderr, MSG, __VA_ARGS__) #define MULTI_HEAP_LOCK(PLOCK) (void) (PLOCK) #define MULTI_HEAP_UNLOCK(PLOCK) (void) (PLOCK) #define MULTI_HEAP_LOCK_INIT(PLOCK) (void) (PLOCK) #define MULTI_HEAP_LOCK_STATIC_INITIALIZER 0 #define MULTI_HEAP_ASSERT(CONDITION, ADDRESS) assert((CONDITION) && "Heap corrupt") #define MULTI_HEAP_BLOCK_OWNER #define MULTI_HEAP_SET_BLOCK_OWNER(HEAD) #define MULTI_HEAP_GET_BLOCK_OWNER(HEAD) (NULL)10 defines /* ... */ #endif // MULTI_HEAP_FREERTOS
Details