Heapless memory pool #191

Merged
muellerr merged 3 commits from heapless-mem-pool into main 2024-05-22 13:16:30 +02:00
Showing only changes of commit 832250d211 - Show all commits

View File

@ -133,6 +133,7 @@ impl Display for StaticPoolAddr {
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum StoreIdError {
InvalidSubpool(u16),
InvalidPacketIdx(u16),
@ -156,6 +157,7 @@ impl Error for StoreIdError {}
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum PoolError {
/// Requested data block is too large
DataTooLarge(usize),
@ -390,6 +392,14 @@ pub mod heapless_mod {
static mut $sizes_list_name: core::mem::MaybeUninit<[usize; $num_blocks]> =
core::mem::MaybeUninit::new([$crate::pool::STORE_FREE; $num_blocks]);
};
($pool_name: ident, $sizes_list_name: ident, $num_blocks: expr, $block_size: expr, $meta_data: meta) => {
#[$meta_data]
static mut $pool_name: core::mem::MaybeUninit<[u8; $num_blocks * $block_size]> =
core::mem::MaybeUninit::new([0; $num_blocks * $block_size]);
#[$meta_data]
static mut $sizes_list_name: core::mem::MaybeUninit<[usize; $num_blocks]> =
core::mem::MaybeUninit::new([$crate::pool::STORE_FREE; $num_blocks]);
};
}
/// A static memory pool similar to [super::StaticMemoryPool] which does not reply on