|
Embedded Artistry libmemory
Memory library for embedded systems (malloc and friends)
|
#include <assert.h>#include <freertos/FreeRTOS.h>#include <freertos/task.h>#include <malloc.h>#include <stdbool.h>#include <stdint.h>#include <stdlib.h>
Go to the source code of this file.
Macros | |
| #define | FREERTOS_HEAP_REGION_CNT 2 |
Functions | |
| static int | cmp_heap (const void *a, const void *b) |
| void | malloc_addblock (void *addr, size_t size) |
| Assign blocks of memory for use by malloc(). More... | |
| __attribute__ ((weak)) | |
| void * | malloc (size_t size) |
| void | free (void *ptr) |
Variables | |
| static const uint8_t | heap_region_max = FREERTOS_HEAP_REGION_CNT |
| Maximum number of heap regions that can be specified. More... | |
| static volatile uint8_t | heap_region_cnt = 0 |
| Current number of allocated heap regions. More... | |
| static HeapRegion_t | heap_regions [FREERTOS_HEAP_REGION_CNT+1] |
| static volatile bool | initialized_ = false |
| #define FREERTOS_HEAP_REGION_CNT 2 |
NOTE: This FreeRTOS malloc implementation requires heap_5.c
Please define the correct heap_region for your project.Your application can define this macro to increase the number of heap regions
Definition at line 26 of file malloc_freertos.c.
| __attribute__ | ( | (weak) | ) |
Definition at line 90 of file malloc_freertos.c.
References cmp_heap(), heap_region_cnt, heap_regions, and initialized_.
|
static |
| void free | ( | void * | ptr | ) |
free should NEVER be called before malloc is init'd
Definition at line 126 of file malloc_freertos.c.
References initialized_.
| void* malloc | ( | size_t | size | ) |
| void malloc_addblock | ( | void * | addr, |
| size_t | size | ||
| ) |
Assign blocks of memory for use by malloc().
malloc_addblock must be called before memory allocation calls are made. In this FreeRTOS implementation, malloc() calls will block until memory has been allocated
Definition at line 69 of file malloc_freertos.c.
References heap_region_cnt, heap_region_max, and heap_regions.
|
static |
Current number of allocated heap regions.
Definition at line 35 of file malloc_freertos.c.
Referenced by __attribute__(), and malloc_addblock().
|
static |
Maximum number of heap regions that can be specified.
Definition at line 32 of file malloc_freertos.c.
Referenced by malloc_addblock().
|
static |
FreeRTOS internal memory pool stucture when using heap_5.c
The block with the lowest starting address should appear first in the array
An additional block is allocated to serve as a NULL terminator
Definition at line 44 of file malloc_freertos.c.
Referenced by __attribute__(), and malloc_addblock().
|
static |
Flag that is used in malloc() to cause competing threads to wait until initialization is completed before allocating memory.
Definition at line 50 of file malloc_freertos.c.
Referenced by __attribute__(), free(), and malloc().