commonlibsse_ng\re\n/
NiTDefaultAllocator.rs1use core::{ffi::c_void, marker::PhantomData, ptr};
2
3use crate::re::NiTCollection::{NiFree, NiMalloc};
4
5#[derive(Debug)]
6#[repr(C)]
7pub struct NiTDefaultAllocator<T> {
8 marker: PhantomData<T>,
9}
10
11impl<T> NiTDefaultAllocator<T> {
12 #[inline]
13 pub fn allocate(&mut self) -> *mut c_void {
14 NiMalloc(core::mem::size_of::<T>()).map_or(ptr::null_mut(), |p| p.cast().as_ptr())
15 }
16
17 #[inline]
18 pub fn deallocate(&mut self, ptr: *mut c_void) {
19 NiFree(ptr);
20 }
21}