@@ -18,15 +18,31 @@ pub(crate) struct MemoryState {
1818}
1919
2020impl MemoryState {
21+ #[ cfg( feature = "luau" ) ]
2122 #[ inline]
2223 pub ( crate ) unsafe fn get ( state : * mut ffi:: lua_State ) -> * mut Self {
2324 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 ( ) ;
2837 }
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 ( ) ;
3046 if ffi:: lua_getallocf ( state, & mut mem_state) != ALLOCATOR {
3147 mem_state = ptr:: null_mut ( ) ;
3248 }
0 commit comments