@@ -18,15 +18,31 @@ pub(crate) struct MemoryState {
18
18
}
19
19
20
20
impl MemoryState {
21
+ #[ cfg( feature = "luau" ) ]
21
22
#[ inline]
22
23
pub ( crate ) unsafe fn get ( state : * mut ffi:: lua_State ) -> * mut Self {
23
24
let mut mem_state = ptr:: null_mut ( ) ;
24
- #[ cfg( feature = "luau" ) ]
25
- {
26
- ffi:: lua_getallocf ( state, & mut mem_state) ;
27
- mlua_assert ! ( !mem_state. is_null( ) , "Luau state has no allocator userdata" ) ;
25
+ ffi:: lua_getallocf ( state, & mut mem_state) ;
26
+ mlua_assert ! ( !mem_state. is_null( ) , "Luau state has no allocator userdata" ) ;
27
+ mem_state as * mut MemoryState
28
+ }
29
+
30
+ #[ cfg( not( feature = "luau" ) ) ]
31
+ #[ rustversion:: since( 1.85 ) ]
32
+ #[ inline]
33
+ pub ( crate ) unsafe fn get ( state : * mut ffi:: lua_State ) -> * mut Self {
34
+ let mut mem_state = ptr:: null_mut ( ) ;
35
+ if !ptr:: fn_addr_eq ( ffi:: lua_getallocf ( state, & mut mem_state) , ALLOCATOR ) {
36
+ mem_state = ptr:: null_mut ( ) ;
28
37
}
29
- #[ cfg( not( feature = "luau" ) ) ]
38
+ mem_state as * mut MemoryState
39
+ }
40
+
41
+ #[ cfg( not( feature = "luau" ) ) ]
42
+ #[ rustversion:: before( 1.85 ) ]
43
+ #[ inline]
44
+ pub ( crate ) unsafe fn get ( state : * mut ffi:: lua_State ) -> * mut Self {
45
+ let mut mem_state = ptr:: null_mut ( ) ;
30
46
if ffi:: lua_getallocf ( state, & mut mem_state) != ALLOCATOR {
31
47
mem_state = ptr:: null_mut ( ) ;
32
48
}
0 commit comments