commonlibsse_ng\re\h/
hkMemoryAllocator.rs1use core::ffi::c_void;
2
3use crate::re::hkBaseTypes::hkResult_CEnum;
4use crate::re::offsets_rtti::RTTI_hkMemoryAllocator;
5use crate::re::offsets_vtable::VTABLE_hkMemoryAllocator;
6use crate::rel::id::VariantID;
7
8#[repr(C)]
9pub struct hkMemoryAllocator {
10 pub vtbl: *const hkMemoryAllocatorVtbl,
11}
12
13const _: () = assert!(core::mem::size_of::<hkMemoryAllocator>() == 0x8);
14
15impl hkMemoryAllocator {
16 pub const RTTI: VariantID = RTTI_hkMemoryAllocator;
18 pub const VTABLE: [VariantID; 1] = VTABLE_hkMemoryAllocator;
20}
21
22#[repr(C)]
24pub struct hkMemoryAllocatorVtbl {
25 pub CxxDrop: unsafe extern "C" fn(this: *mut hkMemoryAllocator), pub BlockAlloc: extern "C" fn(this: *mut hkMemoryAllocator, num_bytes: i32) -> *mut u8, pub BlockFree: extern "C" fn(this: *mut hkMemoryAllocator, ptr: *mut u8, num_bytes: i32), pub BufAlloc:
30 extern "C" fn(this: *mut hkMemoryAllocator, req_num_bytes_in_out: &mut i32) -> *mut u8, pub BufFree: extern "C" fn(this: *mut hkMemoryAllocator, ptr: *mut u8, num_bytes: i32), pub BufRealloc: extern "C" fn(
33 this: *mut hkMemoryAllocator,
34 old_ptr: *mut u8,
35 old_num_bytes: i32,
36 req_num_bytes_in_out: &mut i32,
37 ) -> *mut u8, pub BlockAllocBatch: extern "C" fn(
39 this: *mut hkMemoryAllocator,
40 ptrs_out: *mut *mut u8,
41 num_ptrs: i32,
42 block_size: i32,
43 ), pub BlockFreeBatch: extern "C" fn(
45 this: *mut hkMemoryAllocator,
46 ptrs_in: *mut *mut u8,
47 num_ptrs: i32,
48 block_size: i32,
49 ), pub GetMemoryStatistics:
51 extern "C" fn(this: *mut hkMemoryAllocator, usage: &mut MemoryStatistics), pub GetAllocatedSize:
53 extern "C" fn(this: *mut hkMemoryAllocator, obj: *const c_void, num_bytes: i32) -> i32, pub ResetPeakMemoryStatistics: extern "C" fn(this: *mut hkMemoryAllocator), }
56
57#[commonlibsse_ng_derive_internal::ffi_enum]
58#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
59#[repr(C)]
60pub enum MemoryState {
61 Ok = 0,
62 OutOfMemory = 1,
63}
64
65#[repr(C)]
66#[derive(Debug, Default)]
67pub struct MemoryStatistics {
68 pub allocated: i64, pub inUse: i64, pub peakInUse: i64, pub available: i64, pub totalAvailable: i64, pub largestBlock: i64, }
75const _: () = assert!(core::mem::size_of::<MemoryStatistics>() == 0x30);
76
77impl MemoryStatistics {
78 pub const INFINITE_SIZE: i64 = -1;
79}
80
81#[repr(C)]
82pub struct ExtendedInterface {
83 pub vtbl: *const ExtendedInterfaceVtbl,
84}
85const _: () = assert!(core::mem::size_of::<ExtendedInterface>() == 0x8);
86
87pub type MemoryWalkCallback =
88 unsafe extern "C" fn(start: *mut (), size: usize, allocated: bool, pool: i32, param: *mut ());
89
90#[repr(C)]
91pub struct ExtendedInterfaceVtbl {
92 pub CxxDrop: unsafe extern "C" fn(this: *mut ExtendedInterface), pub GarbageCollect: extern "C" fn(this: *mut ExtendedInterface), pub IncrementalGarbageCollect: extern "C" fn(this: *mut ExtendedInterface, num_blocks: i32), pub SetMemorySoftLimit: extern "C" fn(this: *mut ExtendedInterface, max_memory: usize) -> i32, pub GetMemorySoftLimit: extern "C" fn(this: *const ExtendedInterface) -> usize, pub CanAllocTotal: extern "C" fn(this: *mut ExtendedInterface, num_bytes: i32) -> bool, pub WalkMemory: extern "C" fn(
99 this: *mut ExtendedInterface,
100 callback: MemoryWalkCallback,
101 param: *mut c_void,
102 ) -> hkResult_CEnum,
103}