This module handles block memory allocator features.
More...
|
|
|
#define
|
NRF_BALLOC_DEFAULT_DEBUG_FLAGS
0
|
|
|
Default debug flags for
Block memory allocator
. This is used by the
NRF_BALLOC_DEF
macro. Flags can be changed in
SDK configuration header file
.
|
|
|
|
#define
|
NRF_BALLOC_BLOCK_SIZE
(_element_size, _debug_flags)
ALIGN_NUM
(sizeof(uint32_t), (_element_size))
|
|
|
Get total memory consumed by single block (element size with overhead caused by debug flags).
More...
|
|
|
|
#define
|
NRF_BALLOC_DBG_DEF
(_name, _element_size, _pool_size, _debug_flags)
|
|
|
Create a block allocator instance with custom debug flags.
More...
|
|
|
|
#define
|
NRF_BALLOC_DEF
(_name, _element_size, _pool_size)
NRF_BALLOC_DBG_DEF
(_name, _element_size, _pool_size,
NRF_BALLOC_DEFAULT_DEBUG_FLAGS
)
|
|
|
Create a block allocator instance.
More...
|
|
|
|
#define
|
NRF_BALLOC_INTERFACE_DEC
(_type, _name)
|
|
|
Create a block allocator interface.
More...
|
|
|
|
#define
|
NRF_BALLOC_INTERFACE_CUSTOM_DEF
(_attr, _type, _name, _p_pool)
|
|
|
Define a custom block allocator interface.
More...
|
|
|
|
#define
|
NRF_BALLOC_INTERFACE_DEF
(_type, _name, _p_pool)
NRF_BALLOC_INTERFACE_CUSTOM_DEF
(/* empty */, _type, _name, _p_pool)
|
|
|
Define block allocator interface.
More...
|
|
|
|
#define
|
NRF_BALLOC_INTERFACE_LOCAL_DEF
(_type, _name, _p_pool)
NRF_BALLOC_INTERFACE_CUSTOM_DEF
(static, _type, _name, _p_pool)
|
|
|
Define a local block allocator interface.
More...
|
|
|
This module handles block memory allocator features.
|
#define NRF_BALLOC_BLOCK_SIZE
|
(
|
|
_element_size,
|
|
|
|
|
_debug_flags
|
|
|
)
|
|
ALIGN_NUM
(sizeof(uint32_t), (_element_size))
|
Get total memory consumed by single block (element size with overhead caused by debug flags).
-
Parameters
-
|
[in]
|
_element_size
|
Size of an element.
|
|
[in]
|
_debug_flags
|
Debug flags.
|
|
#define NRF_BALLOC_DBG_DEF
|
(
|
|
_name,
|
|
|
|
|
_element_size,
|
|
|
|
|
_pool_size,
|
|
|
|
|
_debug_flags
|
|
|
)
|
|
|
Value:
static uint8_t _name##_nrf_balloc_pool_stack[(_pool_size)]; \
static uint32_t _name##_nrf_balloc_pool_mem \
{ \
.
p_cb
= &_name##_nrf_balloc_cb, \
.p_stack_base = _name##_nrf_balloc_pool_stack, \
.p_stack_limit = _name##_nrf_balloc_pool_stack + (_pool_size), \
.p_memory_begin = _name##_nrf_balloc_pool_mem, \
}
Create a block allocator instance with custom debug flags.
-
Note
-
This macro reserves memory for the given block allocator instance.
-
Parameters
-
Create a block allocator instance.
-
Note
-
This macro reserves memory for the given block allocator instance.
-
Parameters
-
|
[in]
|
_name
|
Name of the allocator.
|
|
[in]
|
_element_size
|
Size of one element.
|
|
[in]
|
_pool_size
|
Size of the pool.
|
|
#define NRF_BALLOC_INTERFACE_CUSTOM_DEF
|
(
|
|
_attr,
|
|
|
|
|
_type,
|
|
|
|
|
_name,
|
|
|
|
|
_p_pool
|
|
|
)
|
|
|
Value:
_attr _type * _name##_alloc(
void
) \
{ \
ASSERT((_p_pool) != NULL); \
ASSERT((_p_pool)->block_size >= \
} \
\
_attr
void
_name##_free(_type * p_element) \
{ \
ASSERT((_p_pool) != NULL); \
ASSERT((_p_pool)->block_size >= \
nrf_balloc_free((_p_pool), p_element); \
} \
\
_attr uint8_t _name##_max_utilization_get(
void
) \
{ \
ASSERT((_p_pool) != NULL); \
}
Define a custom block allocator interface.
-
Parameters
-
|
[in]
|
_attr
|
Function attribute that will be added to allocator function definition.
|
|
[in]
|
_type
|
Type which is allocated.
|
|
[in]
|
_name
|
Name of the allocator.
|
|
[in]
|
_p_pool
|
Pool from which data will be allocated.
|
|
#define NRF_BALLOC_INTERFACE_DEC
|
(
|
|
_type,
|
|
|
|
|
_name
|
|
|
)
|
|
|
Value:
_type * _name##_alloc(
void
); \
void _name##_free(_type * p_element); \
uint8_t _name##_max_utilization_get(
void
)
Create a block allocator interface.
-
Parameters
-
|
[in]
|
_type
|
Type which is allocated.
|
|
[in]
|
_name
|
Name of the allocator.
|
Define block allocator interface.
-
Parameters
-
|
[in]
|
_type
|
Type which is allocated.
|
|
[in]
|
_name
|
Name of the allocator.
|
|
[in]
|
_p_pool
|
Pool from which data will be allocated.
|
Define a local block allocator interface.
-
Parameters
-
|
[in]
|
_type
|
Type which is allocated.
|
|
[in]
|
_name
|
Name of the allocator.
|
|
[in]
|
_p_pool
|
Pool from which data will be allocated.
|
Function for allocating an element from the pool.
-
Note
-
This module guarantees that the returned memory is aligned to 4.
-
Parameters
-
|
[in]
|
p_pool
|
Pointer to the memory pool from which the element will be allocated.
|
-
Returns
-
Allocated element or NULL if the specified pool is empty.
|
void nrf_balloc_free
|
(
|
nrf_balloc_t
const *
|
p_pool
,
|
|
|
|
void *
|
p_element
|
|
|
)
|
|
|
Function for freeing an element back to the pool.
-
Parameters
-
|
[in]
|
p_pool
|
Pointer to the memory pool.
|
|
[in]
|
p_element
|
Element to be freed.
|
Function for initializing a block memory allocator pool.
-
Parameters
-
|
[out]
|
p_pool
|
Pointer to the pool that is to be initialized.
|
-
Returns
-
NRF_SUCCESS on success, otherwise error code.
|
__STATIC_INLINE uint8_t nrf_balloc_max_utilization_get
|
(
|
nrf_balloc_t
const *
|
p_pool
|
)
|
|
Function for getting maximum memory pool utilization.
-
Parameters
-
|
[in]
|
p_pool
|
Pointer to the memory pool instance.
|
-
Returns
-
Maximum number of elements allocated from the pool.