fn main() {
let mut bytes: [u8; 25] = [0; 25];
for n in 0..bytes.len() {
bytes[n] = (n % 255) as u8;
}
let memory = Buffer::init_from_bytes(&mut bytes);
println!("buffer size: {}", memory.len());
let bytes1 = memory.alloc(12);
if let Some(bytes1) = bytes1 {
println!("bytes1 at-1: {}", bytes1[1]);
}
let bytes2 = memory.alloc_mut(10);
if let Some(bytes2) = bytes2 {
println!("bytes2 at-0: {}", bytes2[0]);
bytes2[0] = 255;
println!("bytes2 at-0 [after=255]: {}", bytes2[0]);
}
let bytes3 = memory.alloc(20);
assert_eq!(None, bytes3);
}
-
Notifications
You must be signed in to change notification settings - Fork 0
Simple thread-safe, rust memory allocator from static buffer
License
xigh/buffer-rs
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Simple thread-safe, rust memory allocator from static buffer
Topics
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published