C API memory pool definitions.
More...
C API memory pool definitions.
- For the complete definition, see
- RTOS C++ API
- Examples
typedef struct my_blk_s
{
int i;
const char* s;
} my_blk_t;
int
{
my_blk_t* blk;
{
}
{
static char pool[1000];
}
}
◆ os_mempool_create
◆ os_mempool_destroy
◆ os_mempool_attr_t
◆ os_mempool_t
Memory pool object storage.
This C structure has the same size as the C++ os::rtos::memory_pool
object and must be initialised with os_mempool_create()
.
Later on a pointer to it can be used both in C and C++ to refer to the memory pool object instance.
The members of this structure are hidden and should not be used directly, but only through specific functions.
- See also
- os::rtos::memory_pool
◆ os_mempool_alloc()
Allocate a memory block.
- Parameters
-
[in] | mempool | Pointer to memory pool object instance. |
- Returns
- Pointer to memory block, or
NULL
if interrupted.
- Warning
- Cannot be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::memory_pool::alloc()
Definition at line 2596 of file os-c-wrapper.cpp.
◆ os_mempool_attr_init()
Initialise the memory pool attributes.
- Parameters
-
[in] | attr | Pointer to memory pool attributes object instance. |
- Returns
- Nothing.
- Warning
- Cannot be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::memory_pool::attributes
Definition at line 2479 of file os-c-wrapper.cpp.
◆ os_mempool_construct()
Construct a statically allocated memory pool object instance.
- Parameters
-
[in] | mempool | Pointer to memory pool object instance storage. |
[in] | name | Pointer to name (may be NULL). |
[in] | blocks | The maximum number of items in the pool. |
[in] | block_size_bytes | The size of an item, in bytes. |
[in] | attr | Pointer to attributes (may be NULL). |
- Returns
- Nothing.
- Note
- Must be paired with
os_mempool_destruct()
.
- Warning
- Cannot be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::memory_pool
Definition at line 2496 of file os-c-wrapper.cpp.
◆ os_mempool_delete()
Destruct the memory pool object instance and deallocate it.
- Parameters
-
[in] | mempool | Pointer to dynamically allocated memory pool object instance. |
- Returns
- Nothing.
Destruct the memory pool and deallocate the dynamically allocated space using the RTOS system allocator.
- Note
- Equivalent of C++
delete ptr_mempool
.
-
Must be paired with
os_mempool_new()
.
- Warning
- Cannot be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::memory_pool
Definition at line 2566 of file os-c-wrapper.cpp.
◆ os_mempool_destruct()
Destruct the statically allocated memory pool object instance.
- Parameters
-
[in] | mempool | Pointer to memory pool object instance. |
- Returns
- Nothing.
- Note
- Must be paired with
os_mempool_construct()
.
- Warning
- Cannot be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::memory_pool
Definition at line 2519 of file os-c-wrapper.cpp.
◆ os_mempool_free()
Free the memory block.
- Parameters
-
[in] | mempool | Pointer to memory pool object instance. |
[in] | block | Pointer to memory block to free. |
- Return values
-
os_ok | The memory block was released. |
EINVAL | The block does not belong to the memory pool. |
- Note
- Can be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::memory_pool::free()
Definition at line 2641 of file os-c-wrapper.cpp.
◆ os_mempool_get_block_size()
Get block size.
- Parameters
-
[in] | mempool | Pointer to memory pool object instance. |
- Returns
- The block size, in bytes.
- Note
- Can be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::memory_pool::block_size()
Definition at line 2686 of file os-c-wrapper.cpp.
◆ os_mempool_get_capacity()
Get memory pool capacity.
- Parameters
-
[in] | mempool | Pointer to memory pool object instance. |
- Returns
- The max number of blocks in the pool.
- Note
- Can be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::memory_pool::capacity()
Definition at line 2656 of file os-c-wrapper.cpp.
◆ os_mempool_get_count()
Get blocks count.
- Parameters
-
[in] | mempool | Pointer to memory pool object instance. |
- Returns
- The number of blocks used from the queue.
- Note
- Can be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::memory_pool::count()
Definition at line 2671 of file os-c-wrapper.cpp.
◆ os_mempool_get_name()
Get the memory pool name.
- Parameters
-
[in] | mempool | Pointer to memory pool object instance. |
- Returns
- Null terminated string.
- Note
- Can be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::memory_pool::name()
Definition at line 2581 of file os-c-wrapper.cpp.
◆ os_mempool_get_pool()
Get the pool storage address.
- Parameters
-
[in] | mempool | Pointer to memory pool object instance. |
- Returns
- Pointer to storage.
- Note
- Can be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::memory_pool::pool()
Definition at line 2746 of file os-c-wrapper.cpp.
◆ os_mempool_is_empty()
Check if the memory pool is empty.
- Parameters
-
[in] | mempool | Pointer to memory pool object instance. |
- Return values
-
true | The memory pool has no allocated blocks. |
false | The memory pool has allocated blocks. |
- Note
- Can be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::memory_pool::empty()
Definition at line 2701 of file os-c-wrapper.cpp.
◆ os_mempool_is_full()
Check if the memory pool is full.
- Parameters
-
[in] | mempool | Pointer to memory pool object instance. |
- Return values
-
true | All memory blocks are allocated. |
false | There are still memory blocks that can be allocated. |
- Note
- Can be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::memory_pool::full()
Definition at line 2716 of file os-c-wrapper.cpp.
◆ os_mempool_new()
Allocate a memory pool object instance and construct it.
- Parameters
-
[in] | name | Pointer to name (may be NULL). |
[in] | blocks | The maximum number of items in the pool. |
[in] | block_size_bytes | The size of an item, in bytes. |
[in] | attr | Pointer to attributes (may be NULL). |
- Returns
- Pointer to new memory pool object instance.
Dynamically allocate the memory pool object instance using the RTOS system allocator and construct it.
- Note
- Equivalent of C++
new memory_pool(...)
.
-
Must be paired with
os_mempool_delete()
.
- Warning
- Cannot be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::memory_pool
Definition at line 2540 of file os-c-wrapper.cpp.
◆ os_mempool_reset()
Reset the memory pool.
- Parameters
-
[in] | mempool | Pointer to memory pool object instance. |
- Return values
-
os_ok | The memory pool was reset. |
EPERM | Cannot be invoked from an Interrupt Service Routines. |
- Warning
- Cannot be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::memory_pool::reset()
Definition at line 2731 of file os-c-wrapper.cpp.
◆ os_mempool_timed_alloc()
Allocate a memory block with timeout.
- Parameters
-
[in] | mempool | Pointer to memory pool object instance. |
[in] | timeout | Timeout to wait, in clock units (ticks or seconds). |
- Returns
- Pointer to memory block, or
NULL
if timeout.
- Warning
- Cannot be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::memory_pool::timed_alloc()
Definition at line 2626 of file os-c-wrapper.cpp.
◆ os_mempool_try_alloc()
Try to allocate a memory block.
- Parameters
-
[in] | mempool | Pointer to memory pool object instance. |
- Returns
- Pointer to memory block, or
NULL
if no memory available.
- Note
- Can be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::memory_pool::try_alloc()
Definition at line 2611 of file os-c-wrapper.cpp.