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
44
45
46
47
48
//! # alloc-madvise
//!
//! Rust-aligned-allocations provides aligned memory allocation utilities for Rust.
//!
//! This crate offers functionality to allocate and manage memory with specific alignment requirements.
//! The main features include:
//!
//! - [`Memory`] - A safe wrapper around aligned memory allocations
//! - [`AllocationError`] - Error type for memory allocation failures
//!
//! # Example
//!
//! ```
//! use alloc_madvise::{Memory, AllocationError};
//!
//! fn main() -> Result<(), AllocationError> {
//! // Allocate 1024 bytes aligned to 64 bytes
//! const SIZE: usize = 1024;
//! const SEQUENTIAL: bool = true;
//! const CLEAR: bool = true;
//! let memory = Memory::allocate(SIZE, SEQUENTIAL, CLEAR)?;
//!
//! // Use the allocated memory...
//! assert_ne!(memory.as_ptr(), std::ptr::null_mut());
//! assert_eq!((memory.as_ptr() as usize) % 64, 0);
//! assert_eq!(memory.len(), SIZE);
//! assert!(!memory.is_empty());
//!
//! // Memory is automatically freed when dropped
//! Ok(())
//! }
//! ```
//!
//! # Features
//!
//! - `ffi`: Enables FFI bindings for C interoperability (enabled by default)
pub use AllocationError;
pub use Memory;