Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72288e2bae | ||
|
|
0e7460009e |
No files matched your search
+15
-10
@@ -62,14 +62,6 @@ static lua_CFunction liblist[] = {
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
// Lua asks for memory using this.
|
|
||||||
static void *LUA_Alloc(void *ud, void *ptr, size_t osize, size_t nsize)
|
|
||||||
{
|
|
||||||
(void)ud;
|
|
||||||
(void)osize;
|
|
||||||
return Z_Realloc(ptr, nsize, PU_LUA, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Panic function Lua calls when there's an unprotected error.
|
// Panic function Lua calls when there's an unprotected error.
|
||||||
// This function cannot return. Lua would kill the application anyway if it did.
|
// This function cannot return. Lua would kill the application anyway if it did.
|
||||||
FUNCNORETURN static int LUA_Panic(lua_State *L)
|
FUNCNORETURN static int LUA_Panic(lua_State *L)
|
||||||
@@ -197,7 +189,7 @@ void LUA_ClearState(void)
|
|||||||
CONS_Printf(M_GetText("Pardon me while I initialize the Lua scripting interface...\n"));
|
CONS_Printf(M_GetText("Pardon me while I initialize the Lua scripting interface...\n"));
|
||||||
|
|
||||||
// allocate state
|
// allocate state
|
||||||
L = lua_newstate(LUA_Alloc, NULL);
|
L = luaL_newstate();
|
||||||
lua_atpanic(L, LUA_Panic);
|
lua_atpanic(L, LUA_Panic);
|
||||||
|
|
||||||
// open base libraries
|
// open base libraries
|
||||||
@@ -373,7 +365,7 @@ void LUA_DumpFile(const char *filename)
|
|||||||
|
|
||||||
static void createMathLibState(void)
|
static void createMathLibState(void)
|
||||||
{
|
{
|
||||||
mL = lua_newstate(LUA_Alloc, NULL);
|
mL = luaL_newstate();
|
||||||
lua_atpanic(mL, LUA_Panic);
|
lua_atpanic(mL, LUA_Panic);
|
||||||
|
|
||||||
// open only enum lib
|
// open only enum lib
|
||||||
@@ -1465,3 +1457,16 @@ int Lua_CreateFieldTable(lua_State *L, const char *const lst[])
|
|||||||
|
|
||||||
return luaL_ref(L, LUA_REGISTRYINDEX);
|
return luaL_ref(L, LUA_REGISTRYINDEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t LUA_MemoryUsage(void)
|
||||||
|
{
|
||||||
|
size_t usage = 0;
|
||||||
|
|
||||||
|
if (gL)
|
||||||
|
usage += lua_gc(gL, LUA_GCCOUNT, 0);
|
||||||
|
|
||||||
|
if (mL)
|
||||||
|
usage += lua_gc(mL, LUA_GCCOUNT, 0);
|
||||||
|
|
||||||
|
return usage;
|
||||||
|
}
|
||||||
@@ -82,6 +82,9 @@ int Lua_optoption(lua_State *L, int narg, int def, int list_ref);
|
|||||||
int Lua_CreateFieldTable(lua_State *L, const char *const lst[]);
|
int Lua_CreateFieldTable(lua_State *L, const char *const lst[]);
|
||||||
void LUA_HookNetArchive(lua_CFunction archFunc, savebuffer_t *save);
|
void LUA_HookNetArchive(lua_CFunction archFunc, savebuffer_t *save);
|
||||||
|
|
||||||
|
// Returns lua memory usage in kbytes
|
||||||
|
size_t LUA_MemoryUsage(void);
|
||||||
|
|
||||||
// Console wrapper
|
// Console wrapper
|
||||||
void COM_Lua_f(void);
|
void COM_Lua_f(void);
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -663,8 +663,8 @@ static void Command_Memfree_f(void)
|
|||||||
|
|
||||||
Z_CheckHeap(-1);
|
Z_CheckHeap(-1);
|
||||||
CONS_Printf("\x82%s", M_GetText("Memory Info\n"));
|
CONS_Printf("\x82%s", M_GetText("Memory Info\n"));
|
||||||
CONS_Printf(M_GetText("Total heap used : %7s KB\n"), sizeu1(Z_TotalUsage()>>10));
|
CONS_Printf(M_GetText("Total heap used : %7s KB\n"), sizeu1((Z_TotalUsage()>>10) + LUA_MemoryUsage()));
|
||||||
CONS_Printf(M_GetText("Lua : %7s KB\n"), sizeu1(Z_TagUsage(PU_LUA)>>10));
|
CONS_Printf(M_GetText("Lua : %7s KB\n"), sizeu1(LUA_MemoryUsage())); // No longer uses z_zone memory but for consistency keep it here
|
||||||
CONS_Printf(M_GetText("Static : %7s KB\n"), sizeu1(Z_TagUsage(PU_STATIC)>>10));
|
CONS_Printf(M_GetText("Static : %7s KB\n"), sizeu1(Z_TagUsage(PU_STATIC)>>10));
|
||||||
CONS_Printf(M_GetText("Static (sound) : %7s KB\n"), sizeu1(Z_TagUsage(PU_SOUND)>>10));
|
CONS_Printf(M_GetText("Static (sound) : %7s KB\n"), sizeu1(Z_TagUsage(PU_SOUND)>>10));
|
||||||
CONS_Printf(M_GetText("Static (music) : %7s KB\n"), sizeu1(Z_TagUsage(PU_MUSIC)>>10));
|
CONS_Printf(M_GetText("Static (music) : %7s KB\n"), sizeu1(Z_TagUsage(PU_MUSIC)>>10));
|
||||||
|
|||||||
Reference in new issue
Block a user