Embedded Artistry Framework
Embedded Systems C++ Framework
Functions
malloc_framework_rtos.cpp File Reference
#include <heap.hpp>
#include <malloc.h>
Include dependency graph for malloc_framework_rtos.cpp:

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)
 Allocates size bytes of uninitialized storage. More...
 
void free (void *ptr)
 Deallocates allocated memory space. More...
 

Function Documentation

◆ __attribute__()

__attribute__ ( (weak)  )

◆ free()

void free ( void *  ptr)

Deallocates allocated memory space.

Deallocates the space previously allocated by

See also
malloc,
calloc,
realloc. If ptr is a null pointer, the function does nothing.

The behavior is undefined if the value of ptr does not equal a value returned earlier by

See also
malloc,
calloc,
realloc.

The behavior is undefined if the memory area referred to by ptr has already been deallocated, that is, free() or realloc has already been called with ptr as the argument and no calls to malloc, calloc or realloc resulted in a pointer equal to ptr afterwards.

The behavior is undefined if after free returns, an access is made through the pointer ptr (unless another allocation function happened to result in a pointer value equal to ptr)

Parameters
ptrpointer to the memory to deallocate

References embvm::VirtualHeap< THeapImpl >::free().

◆ malloc()

void* malloc ( size_t  size)

Allocates size bytes of uninitialized storage.

If size is zero, the behavior is implementation defined (null pointer may be returned, or some non-null pointer may be returned that may not be used to access storage, but has to be passed to

See also
free). malloc is thread-safe: it behaves as though only accessing the memory locations visible through its argument, and not any static storage.
Parameters
sizenumber of bytes to allocate
Returns
On success, returns the pointer to the beginning of newly allocated memory. The returned pointer must be deallocated with
See also
free() or
realloc(). On failure, returns a null pointer.

References embvm::VirtualHeap< THeapImpl >::alloc().

◆ 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()

References embvm::VirtualHeap< THeapImpl >::addBlock().