diff --git a/polymer/eduke32/build/include/lunatic.h b/polymer/eduke32/build/include/lunatic.h index 1b7fd3b7f..d2c9b71a2 100644 --- a/polymer/eduke32/build/include/lunatic.h +++ b/polymer/eduke32/build/include/lunatic.h @@ -40,7 +40,7 @@ extern void (*L_OutOfMemFunc)(void); int L_CreateState(L_State *estate, const char *name, void (*StateSetupFunc)(lua_State *)); void L_DestroyState(L_State *estate); int L_RunOnce(L_State *estate, const char *fn); -int L_RunString(L_State *estate, char *buf, int dofreebuf, int size, const char *name); +int L_RunString(L_State *estate, char const *buf, int size, const char *name); static inline int L_IsInitialized(const L_State *estate) { return (estate->L != NULL); } diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index 451b8b698..a532d2583 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -9168,7 +9168,7 @@ int32_t initengine(void) { char *luastr = "_LUNATIC_AUX=true; decl=require('ffi').cdef; require'defs_common'"; - if (L_RunString(&g_engState, luastr, 0, -1, "eng")) + if (L_RunString(&g_engState, luastr, -1, "eng")) return E_FatalError("Failed setting up engine Lua state"); } #endif diff --git a/polymer/eduke32/build/src/lunatic.c b/polymer/eduke32/build/src/lunatic.c index 4a90c4299..e609f8869 100644 --- a/polymer/eduke32/build/src/lunatic.c +++ b/polymer/eduke32/build/src/lunatic.c @@ -187,7 +187,7 @@ static void L_ErrorPrint(const char *errmsg) // size < 0: length of is determined using strlen() // size >= 0: size given, for loading of LuaJIT bytecode -int L_RunString(L_State *estate, char *buf, int dofreebuf, int size, const char *name) +int L_RunString(L_State *estate, char const *buf, int size, const char *name) { int32_t i; lua_State *L = estate->L; @@ -202,8 +202,6 @@ int L_RunString(L_State *estate, char *buf, int dofreebuf, int size, const char else i = luaL_loadbuffer(L, buf, size, name); Bassert(lua_gettop(L)==2); - if (dofreebuf) - Bfree(buf); if (i == LUA_ERRMEM) L_OutOfMemFunc(); @@ -243,5 +241,7 @@ int L_RunOnce(L_State *estate, const char *fn) if (i != 0) return i; - return L_RunString(estate, buf, 1, -1, fn); + int const retval = L_RunString(estate, buf, -1, fn); + Bfree(buf); + return retval; } diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index c7151eee4..b2ff0c50e 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -8908,7 +8908,7 @@ static int32_t osdcmd_lua(const osdfuncparm_t *parm) return OSDCMD_OK; } - ret = L_RunString(&g_EmState, (char *)parm->parms[0], 0, -1, "console"); + ret = L_RunString(&g_EmState, parm->parms[0], -1, "console"); if (ret != 0) OSD_Printf("Error running the Lua code (error code %d)\n", ret); else @@ -9988,7 +9988,7 @@ int32_t ExtPostStartupWindow(void) { extern const char luaJIT_BC_defs_m32[]; - int32_t i = L_RunString(&g_EmState, (char *)luaJIT_BC_defs_m32, 0, + int32_t i = L_RunString(&g_EmState, luaJIT_BC_defs_m32, LUNATIC_DEFS_M32_BC_SIZE, "defs_m32.ilua"); if (i != 0) { diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index f2a279f55..d7538cf30 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -11049,7 +11049,7 @@ void El_CreateGameState(void) { extern const char luaJIT_BC_defs[]; - if ((i = L_RunString(&g_ElState, (char *)luaJIT_BC_defs, 0, + if ((i = L_RunString(&g_ElState, luaJIT_BC_defs, LUNATIC_DEFS_BC_SIZE, "defs.ilua"))) { initprintf("Lunatic: Error preparing global ELua state (code %d)\n", i); diff --git a/polymer/eduke32/source/osdcmds.c b/polymer/eduke32/source/osdcmds.c index 40c0e7e58..c4ace2afd 100644 --- a/polymer/eduke32/source/osdcmds.c +++ b/polymer/eduke32/source/osdcmds.c @@ -698,7 +698,7 @@ static int32_t osdcmd_lua(const osdfuncparm_t *parm) // For the 'lua' OSD command, don't make errors appear on-screen: el_addNewErrors = 0; - ret = L_RunString(&g_ElState, (char *)parm->parms[0], 0, -1, "console"); + ret = L_RunString(&g_ElState, parm->parms[0], -1, "console"); el_addNewErrors = 1; if (ret != 0)