commonlibsse_ng\re\i/
IMemoryStore.rs1use crate::re::IMemoryStoreBase::{IMemoryStoreBase, IMemoryStoreBaseVtbl};
2use crate::re::offsets_rtti::RTTI_IMemoryStore;
3use crate::re::offsets_vtable::VTABLE_IMemoryStore;
4use crate::rel::id::VariantID;
5
6#[repr(C)]
8#[derive(Debug, Clone, PartialEq)]
9pub struct IMemoryStore {
10 pub __base: IMemoryStoreBase,
11}
12const _: () = assert!(std::mem::size_of::<IMemoryStore>() == 0x8);
13
14impl Default for IMemoryStore {
15 fn default() -> Self {
16 Self::new()
17 }
18}
19
20impl IMemoryStore {
21 pub const RTTI: VariantID = RTTI_IMemoryStore;
23
24 pub const VTABLE: [VariantID; 1] = VTABLE_IMemoryStore;
26
27 pub const fn new() -> Self {
28 Self { __base: IMemoryStoreBase::new() }
29 }
30
31 #[inline]
33 pub fn allocate_align(&mut self, size: usize, alignment: u32) -> *mut u8 {
34 unsafe { (self.vtable().AllocateAlignImpl)(self, size, alignment) }
35 }
36
37 #[inline]
39 pub fn deallocate_align(&mut self, block: &mut *mut u8) {
40 unsafe { (self.vtable().DeallocateAlignImpl)(self, block) }
41 }
42
43 #[inline]
45 pub fn try_allocate(&mut self, size: usize, alignment: u32) -> *mut u8 {
46 unsafe { (self.vtable().TryAllocateImpl)(self, size, alignment) }
47 }
48
49 #[inline]
50 const fn vtable(&self) -> &'static IMemoryStoreVtbl {
51 unsafe { &*self.__base.vtable.cast::<IMemoryStoreVtbl>() }
52 }
53}
54
55#[repr(C)]
57pub struct IMemoryStoreVtbl {
58 pub __base: IMemoryStoreBaseVtbl,
59
60 pub AllocateAlignImpl:
61 unsafe extern "C" fn(this: *mut IMemoryStore, size: usize, alignment: u32) -> *mut u8,
62 pub DeallocateAlignImpl: unsafe extern "C" fn(this: *mut IMemoryStore, block: *mut *mut u8),
63 pub TryAllocateImpl:
64 unsafe extern "C" fn(this: *mut IMemoryStore, size: usize, alignment: u32) -> *mut u8,
65}