How dropbox/rust-alloc-no-stdlib works
Project type and purpose
• This is an open-source Rust library (“crate”) named alloc-no-stdlib.
• Purpose: provide a pluggable framework for dynamic memory allocation in no_std environments, with multiple allocation strategies (stack, heap, calloc, global, uninitialized).
File structure
• Top level:
• Cargo.toml, README.md, LICENSE, CI config (.travis.yml)
• alloc-stdlib/ – a companion crate that re-exports std-based allocators when the standard library is available
• src/ – the main alloc-no-stdlib crate:
• allocator.rs – core traits and types
• stack_allocator.rs – stack-based freelist implementation
• bin examples under src/bin/
• init.rs, tests.rs, and a subfolder allocated_memory/ with macros (declare_stack_allocator_struct!, define_allocator_memory_pool!, etc.)
• tests/ – integration tests for the crate
• alloc-stdlib/src – analogous modules for std-enabled allocation
README for additional insights
• Describes six allocation modes: stack, heap (initialized and uninitialized), heap with single preallocated pool, calloc, static global buffer
• Shows use of Rust macros to declare allocator structs and define memory pools
• Mentions unsafe C FFI for calloc/malloc/free
Detail
• Every allocation strategy as its own component
• Feature-flag path: std feature enables alloc-stdlib crate and std_alloc.rs
• Macro expansion path so it’s clear how users generate concrete types
• Tests and examples as consumers of the public API