Don't allocate extra byte for userdata (luau)

This commit is contained in:
Alex Orlenko 2022-10-09 13:56:06 +01:00
parent e523fb2c86
commit cfa959e599
No known key found for this signature in database
GPG key ID: 4C150C250863B96D

View file

@ -313,7 +313,7 @@ pub unsafe fn push_userdata<T>(state: *mut ffi::lua_State, t: T, protect: bool)
ptr::drop_in_place(ud as *mut T);
}
let size = mem::size_of::<T>() + 1;
let size = mem::size_of::<T>();
let ud = if protect {
protect_lua!(state, 0, 1, |state| {
ffi::lua_newuserdatadtor(state, size, destructor::<T>) as *mut T