ps-alloc 0.1.0-9

a reasonably safe allocator
Documentation
//! A reasonably safe allocator: a thin, checked wrapper over [`std::alloc`] exposing
//! C-style [`alloc`], [`free`], and [`realloc`].
//!
//! Every allocation is prefixed with a hidden header storing a marker and the
//! allocation's size, which lets the crate detect some misuse (double frees, corrupted
//! or foreign pointers) at runtime, on a best-effort basis. All allocations are aligned
//! to [`HEADER_SIZE`] (16) bytes.
//!
//! Any error other than `NullPtr` returned by [`free`] or [`realloc`] (or `realloc`'s
//! recoverable `NewAllocationFailed`) indicates that the program is already in an
//! undefined state.
//!
//! # Example
//!
//! ```
//! # fn main() -> Result<(), ps_alloc::AllocationError> {
//! let ptr = ps_alloc::alloc(64)?;
//!
//! unsafe {
//!     ptr.write(42);
//!     assert_eq!(ptr.read(), 42);
//!
//!     ps_alloc::free(ptr).expect("the pointer came from alloc");
//! }
//! # Ok(())
//! # }
//! ```

#![warn(missing_docs)]
#![warn(unsafe_op_in_unsafe_fn)]

mod alloc;
mod error;
mod free;
mod header;
mod marker;
mod realloc;

pub use alloc::alloc;
pub use error::{AllocationError, DeallocationError, ReallocationError};
pub use free::free;
pub use header::HEADER_SIZE;
pub use realloc::realloc;