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
//
// Copyright 2017 yvt, all rights reserved.
//
// Licensed under the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>. This file may
// not be copied, modified,or distributed except
// according to those terms.
//
//! Dynamic suballocators for external memory (e.g., Vulkan device memory).
//!
//! # Examples
//!
//! ```
//! let mut tlsf = xalloc::SysTlsf::new(8u32);
//!
//! // Allocate regions
//! let (region1, offset1) = tlsf.alloc(4).unwrap();
//! let (region2, offset2) = tlsf.alloc(4).unwrap();
//! println!("allocated #1: {:?}", (&region1, offset1));
//! println!("allocated #2: {:?}", (&region2, offset2));
//!
//! // Deallocate a region
//! tlsf.dealloc(region1).unwrap();
//!
//! // Now we can allocate again
//! tlsf.alloc(2).unwrap();
//! tlsf.alloc(2).unwrap();
//! ```
//!
//! # Feature Flags
//!
//! - `nightly` — Enables optimizations which currently require a Nightly Rust
//!   compiler.
//!
#![cfg_attr(feature = "nightly", feature(nonzero))]
pub extern crate num_traits;
pub extern crate num_integer;

pub mod arena;
pub mod tlsf;
pub mod int;

pub use self::tlsf::{Tlsf, SafeTlsf, SysTlsf, TlsfBlock};