Embedded Artistry libmemory
Memory library for embedded systems (malloc and friends)
malloc_framework_rtos.cpp File Reference
#include <heap.hpp>
#include <malloc.h>
Include dependency graph for malloc_framework_rtos.cpp:

Go to the source code of this file.

Functions

void malloc_addblock (void *addr, size_t size)
 Assign blocks of memory for use by malloc(). More...
 
 __attribute__ ((weak)) void malloc_init()
 
void * malloc (size_t size)
 
void free (void *ptr)
 

Function Documentation

◆ __attribute__()

__attribute__ ( (weak)  )

Definition at line 14 of file malloc_framework_rtos.cpp.

15 {
16  os::Heap::init();
17 }

◆ free()

void free ( void *  ptr)

Definition at line 24 of file malloc_framework_rtos.cpp.

25 {
26  os::Heap::free(ptr);
27 }
void free(void *ptr)

◆ malloc()

void* malloc ( size_t  size)

Definition at line 19 of file malloc_framework_rtos.cpp.

20 {
21  return os::Heap::alloc(size);
22 }

◆ malloc_addblock()

void malloc_addblock ( void *  addr,
size_t  size 
)

Assign blocks of memory for use by malloc().

Initializes the malloc() backend with a memory address and memory pool size. This memory is assumed to be owned by malloc() and is vended out when memory is requested. Multiple blocks can be added.

NOTE: This API must be called before malloc() can be used. If you call malloc() before allocating memory, malloc() will return NULL because there is no available memory to provide to the user.

Parameters
addrPointer to the memory block address that you are providing to malloc()
sizeSize of the memory block that you are providing to malloc()

Definition at line 9 of file malloc_framework_rtos.cpp.

10 {
11  os::Heap::addBlock(addr, size);
12 }