Skip to content

Commit

Permalink
zephyr: alloc: Add some documentation to the allocator
Browse files Browse the repository at this point in the history
Write docs for the global allocator.  This will also trigger bringing in
the documentation for the module, which explains how to use the
allocator.

Signed-off-by: David Brown <[email protected]>
  • Loading branch information
d3zd3z committed Sep 17, 2024
1 parent f66ae03 commit 321ea12
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion zephyr/src/alloc_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ extern "C" {
fn free(ptr: *mut u8);
}

/// An allocator that uses Zephyr's allocation primitives.
///
/// This is exported for documentation purposes, this module does contain an instance of the
/// allocator as well.
pub struct ZephyrAllocator;

unsafe impl GlobalAlloc for ZephyrAllocator {
Expand All @@ -83,5 +87,6 @@ unsafe impl GlobalAlloc for ZephyrAllocator {
}
}

/// The global allocator built around the Zephyr malloc/free.
#[global_allocator]
static ZEPHYR_ALLOCATOR: ZephyrAllocator = ZephyrAllocator;
pub static ZEPHYR_ALLOCATOR: ZephyrAllocator = ZephyrAllocator;

0 comments on commit 321ea12

Please sign in to comment.