Derive Default for Lua::MemoryInfo

This commit is contained in:
Alex Orlenko 2022-06-27 13:57:15 +01:00
parent ff0d923aae
commit 113f91ace3
No known key found for this signature in database
GPG key ID: 4C150C250863B96D

View file

@ -126,6 +126,7 @@ pub(crate) struct ExtraData {
sandboxed: bool,
}
#[derive(Default)]
struct MemoryInfo {
used_memory: isize,
memory_limit: isize,
@ -433,10 +434,7 @@ impl Lua {
let use_rust_allocator = !(cfg!(feature = "luajit") && cfg!(not(feature = "vendored")));
let (state, mem_info) = if use_rust_allocator {
let mem_info = Box::into_raw(Box::new(MemoryInfo {
used_memory: 0,
memory_limit: 0,
}));
let mem_info = Box::into_raw(Box::new(MemoryInfo::default()));
let state = ffi::lua_newstate(allocator, mem_info as *mut c_void);
(state, mem_info)
} else {