simplify LUA_Alloc

Z_Realloc already handles everything internally, no need to manually free anything
This commit is contained in:
Alug 2026-01-21 19:49:26 +01:00 committed by NepDisk
parent 526a8390f5
commit 5cc8998974
2 changed files with 30 additions and 33 deletions

View file

@ -33,7 +33,7 @@ extern CV_PossibleValue_t Color_cons_t[];
extern UINT8 skincolor_modified[];
boolean LUA_CallAction(enum actionnum actionnum, mobj_t *actor);
state_t *astate;
state_t *astate = NULL;
enum sfxinfo_read {
sfxinfor_name = 0,

View file

@ -77,11 +77,7 @@ static lua_CFunction liblist[] = {
static void *LUA_Alloc(void *ud, void *ptr, size_t osize, size_t nsize)
{
(void)ud;
if (nsize == 0) {
if (osize != 0)
Z_Free(ptr);
return NULL;
} else
(void)osize;
return Z_Realloc(ptr, nsize, PU_LUA, NULL);
}
@ -690,7 +686,8 @@ void LUA_ClearState(void)
lua_setfield(L, LUA_REGISTRYINDEX, LREG_METATABLES);
// open srb2 libraries
for(i = 0; liblist[i]; i++) {
for (i = 0; liblist[i]; i++)
{
lua_pushcfunction(L, liblist[i]);
lua_call(L, 0, 0);
}