Zephyr API Documentation
3.6.99
A Scalable Open Source RTOS
|
Memory heaps based on memory attributes. More...
Functions | |
int | mem_attr_heap_pool_init (void) |
Init the memory pool. | |
void * | mem_attr_heap_alloc (uint32_t attr, size_t bytes) |
Allocate memory with a specified attribute and size. | |
void * | mem_attr_heap_aligned_alloc (uint32_t attr, size_t align, size_t bytes) |
Allocate aligned memory with a specified attribute, size and alignment. | |
void | mem_attr_heap_free (void *block) |
Free the allocated memory. | |
const struct mem_attr_region_t * | mem_attr_heap_get_region (void *addr) |
Get a specific memory region descriptor for a provided address. | |
Memory heaps based on memory attributes.
#include <zephyr/mem_mgmt/mem_attr_heap.h>
Allocate aligned memory with a specified attribute, size and alignment.
Allocates a block of memory of the specified size in bytes and with a specified capability / attribute. Takes an additional parameter specifying a power of two alignment in bytes.
attr | capability / attribute requested for the memory block. |
align | power of two alignment for the returned pointer in bytes. |
bytes | requested size of the allocation in bytes. |
ptr | a valid pointer to the allocated memory. |
NULL | if no memory is available with that attribute and size. |
#include <zephyr/mem_mgmt/mem_attr_heap.h>
Allocate memory with a specified attribute and size.
Allocates a block of memory of the specified size in bytes and with a specified capability / attribute. The attribute is used to select the correct memory heap to allocate memory from.
attr | capability / attribute requested for the memory block. |
bytes | requested size of the allocation in bytes. |
ptr | a valid pointer to the allocated memory. |
NULL | if no memory is available with that attribute and size. |
void mem_attr_heap_free | ( | void * | block | ) |
#include <zephyr/mem_mgmt/mem_attr_heap.h>
Free the allocated memory.
Used to free the passed block of memory that must be the return value of a previously call to mem_attr_heap_alloc or mem_attr_heap_aligned_alloc.
block | block to free, must be a pointer to a block allocated by mem_attr_heap_alloc or mem_attr_heap_aligned_alloc. |
const struct mem_attr_region_t * mem_attr_heap_get_region | ( | void * | addr | ) |
#include <zephyr/mem_mgmt/mem_attr_heap.h>
Get a specific memory region descriptor for a provided address.
Finds the memory region descriptor struct controlling the provided pointer.
addr | address to be found, must be a pointer to a block allocated by mem_attr_heap_alloc or mem_attr_heap_aligned_alloc. |
str | pointer to a memory region structure the address belongs to. |
int mem_attr_heap_pool_init | ( | void | ) |
#include <zephyr/mem_mgmt/mem_attr_heap.h>
Init the memory pool.
This must be the first function to be called to initialize the memory pools from all the memory regions with the a software attribute.
0 | on success. |
-EALREADY | if the pool was already initialized. |
-ENOMEM | too many regions already allocated. |