Skip to content

bbusn/slab_allocator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


slab allocator

A minimal slab allocator in rust no_std

License: GPL v3 Rust



📖 About

A simple slab allocator that manages fixed-size objects in pages. It's designed for no_std environments where you need efficient memory allocation without the standard library.

The allocator:

  • Organizes memory into 4KB pages
  • Maintains a free list for quick allocation/deallocation
  • Automatically handles alignment requirements
  • Reuses freed memory efficiently

💻 Installation

Linux - x86_64

cargo run --target x86_64-unknown-linux-gnu

Linux - aarch64

cargo run --target aarch64-unknown-linux-gnu

🚀 Usage

use slab_allocator::SlabAllocator;
use core::ptr::NonNull;

let mut allocator = SlabAllocator::new(64); // Allocate objects of size 64 bytes

// Allocate an object
if let Some(ptr) = allocator.alloc() {
    // Use the memory...

    // Free it when done
    allocator.free(ptr);
}

🧪 Testing

Run the test suite:

cargo test



About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages