1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//! 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(())
//! # }
//! ```
pub use alloc;
pub use ;
pub use free;
pub use HEADER_SIZE;
pub use realloc;