libwfa/
mm_allocator.rs

1use crate::bindings::*;
2
3#[repr(C)]
4pub struct MMAllocator {
5    allocator: *mut mm_allocator_t,
6}
7
8// TODO need to track the items that have actually been allocated, too
9impl Drop for MMAllocator {
10    fn drop(&mut self) {
11        unsafe {
12            mm_allocator_delete(self.allocator);
13        }
14    }
15}
16
17impl MMAllocator {
18    pub fn new(buffer_size: u64) -> Self {
19        let allocator = unsafe { mm_allocator_new(buffer_size) };
20        Self { allocator }
21    }
22
23    pub fn alloc_ptr(&self) -> *mut mm_allocator_t {
24        self.allocator
25    }
26}