/deblockator

A global allocator to wrap fixed size block allocators

Primary LanguageRustMIT LicenseMIT

deblockator

A platform-agnostic memory allocator designed for block allocators.

TravisCI Codecov Source CargoMake Changelog Crate Documentation

Introduction

The PS Vita provides a kernel API that allows to allocate memory blocks in the console RAM. However, the kernel will only ever allocate blocks of 4kB-aligned memory. While the VitaSDK newlib port uses a 32MB sized heap in a single memory block, it is not the most efficient to do so considering there is a proper allocator available.

The deblockator allocator relies on another allocator to obtain data blocks, and then uses a classic linked-list approachs to provide smaller memory chunks within those blocks. This allows growing a virtually infinite heap without needing to preallocate a large block on startup.

Usage

Add this crate to Cargo.toml:

[dependencies.deblockator]
git = "https://github.com/vita-rust/deblockator"

PS Vita

You'll need to have the armv7-vita-eabihf target specification in your $RUST_TARGET_PATH. If you don't have it, you can find in its dedicated git repository.

When compiling for the PS Vita, use the Vitallocator struct from the vitallocator crate and wrap it within the Deblockator struct:

#![feature(global_allocator)]
extern crate deblockator;
extern crate vitallocator;

use deblockator::Deblockator;
use vitallocator::Vitallocator;

#[global_allocator]
static ALLOC: Deblockator = Deblockator::new(Vitallocator::new());

Compiling to the PS Vita requires the psp2-sys crate.

Credits