offset_allocator_2/
ext.rs1use crate::{small_float, Allocator};
4
5pub fn min_allocator_size(needed_object_size: u32) -> u32 {
8 small_float::float_to_uint(small_float::uint_to_float_round_up(needed_object_size))
9}
10
11impl Allocator {
12 pub fn is_empty(&self) -> bool {
14 self.free_storage == self.size
15 }
16}
17
18#[cfg(test)]
19mod tests {
20 use crate::*;
21
22 #[test]
23 fn ext_is_empty() {
24 let mut allocator: Allocator<u32> = Allocator::new(1024);
25 assert!(allocator.is_empty());
26
27 let allocation = allocator.allocate(1).unwrap();
28 assert!(!allocator.is_empty());
29
30 allocator.free(allocation);
31 assert!(allocator.is_empty());
32 }
33}