Bedtime. /Memory Management

Memory Management

Dynamic memory allocation from FreeRTOS heap

void* os_malloc(size_t size)

Allocate memory from FreeRTOS heap

size_tsizeNumber of bytes to allocate

Returns — Pointer to allocated memory, or NULL if out of memory

void* buffer = os_malloc(1024);
if (buffer) {
    // Use buffer
    os_free(buffer);
}

Note — Memory is limited - always check return values

void os_free(void* ptr)

Free memory allocated with os_malloc

void*ptrPointer returned by os_malloc (NULL is safely ignored)