Skip to main content

luaur_vm/functions/
lua_s_free.rs

1use crate::functions::lua_m_freegco::luaM_freegco_;
2use crate::functions::unlinkstr::unlinkstr;
3use crate::macros::sizestring::sizestring;
4use crate::records::gc_object::GCObject;
5use crate::records::lua_page::lua_Page;
6use crate::records::t_string::TString;
7use crate::type_aliases::lua_state::lua_State;
8use luaur_common::macros::luau_assert::LUAU_ASSERT;
9
10#[allow(non_snake_case)]
11pub unsafe fn luaS_free(l: *mut lua_State, ts: *mut TString, page: *mut lua_Page) {
12    if unlinkstr(l, ts) {
13        (*(*l).global).strt.nuse = (*(*l).global).strt.nuse.wrapping_sub(1);
14    } else {
15        LUAU_ASSERT!((*ts).next.is_null());
16    }
17
18    luaM_freegco_(
19        l,
20        ts as *mut GCObject,
21        sizestring((*ts).len as usize),
22        (*ts).hdr.memcat,
23        page,
24    );
25}
26
27#[allow(unused_imports)]
28pub use luaS_free as lua_s_free;