https://github.com/kyza/only_alloc
An allocator wrapper that disables deallocating memory within it.
https://github.com/kyza/only_alloc
Last synced: 4 months ago
JSON representation
An allocator wrapper that disables deallocating memory within it.
- Host: GitHub
- URL: https://github.com/kyza/only_alloc
- Owner: Kyza
- License: mit
- Created: 2025-05-06T03:23:23.000Z (about 1 year ago)
- Default Branch: trunk
- Last Pushed: 2025-05-06T23:22:42.000Z (about 1 year ago)
- Last Synced: 2025-05-31T01:54:07.883Z (about 1 year ago)
- Language: Rust
- Homepage:
- Size: 11.7 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# only_alloc
[](https://github.com/kyza/only_alloc)
[](https://crates.io/crates/only_alloc)
[](https://docs.rs/only_alloc)
`only_alloc` wraps another allocator and disables deallocating memory within it.
It can be used either as a global allocator or as an allocator from `#![feature(allocator_api)]`.
It can be used with `no_std` environments and it contains zero dependencies.
```rs
use mimalloc::MiMalloc;
use only_alloc::GlobalOnlyAlloc;
#[global_allocator]
static ONLY_MIMALLOC: GlobalOnlyAlloc = GlobalOnlyAlloc(MiMalloc);
```
## Installation
```bash
cargo add only_alloc
```
## Why?
Maybe you have a use for this because I don't. It might be microscopically faster for CLI tools. I simply enjoyed writing it.