Try fix glib preallocating too much space for sound freeslots

This commit is contained in:
indev committed 2024-06-20 16:55:58 +03:00
1 parent 3412bb5380
commit c13e780f29
1 file changed
+10 -7
+10 -7
View File
@@ -9130,12 +9130,15 @@ int LUA_EnumLib(lua_State *L)
char *str = NULL;
int size = 0;
// Sound enum tables preallocated for sfx_freeslot0 elements because using NUMSFX may be too
// much if number of skins increased a lot (because of skinsound freeslots)
/* SFX (SFX_) */
lua_pushcfunction(L, lua_glib_new_enum);
lua_createtable(L, 0, NUMSFX);
lua_createtable(L, 0, sfx_freeslot0);
for (int i = 0; i < NUMSFX; i++)
{
if (!S_sfx[i].name) continue;
if (!S_sfx[i].name || !S_sfx[i].priority) continue;
if (lua_enumlib_sprintf_upper(&str, &size, "SFX_%s", S_sfx[i].name) == NULL)
return luaL_error(L, "Ran out of memory.");
@@ -9150,10 +9153,10 @@ int LUA_EnumLib(lua_State *L)
/* SFX (DS) */
lua_pushcfunction(L, lua_glib_new_enum);
lua_createtable(L, 0, NUMSFX);
lua_createtable(L, 0, sfx_freeslot0);
for (int i = 0; i < NUMSFX; i++)
{
if (!S_sfx[i].name) continue;
if (!S_sfx[i].name || !S_sfx[i].priority) continue;
if (lua_enumlib_sprintf_upper(&str, &size, "DS%s", S_sfx[i].name) == NULL)
return luaL_error(L, "Ran out of memory.");
@@ -9188,10 +9191,10 @@ int LUA_EnumLib(lua_State *L)
{
/* SFX (sfx_) */
lua_pushcfunction(L, lua_glib_new_enum);
lua_createtable(L, 0, NUMSFX);
lua_createtable(L, 0, sfx_freeslot0);
for (int i = 0; i < NUMSFX; i++)
{
if (!S_sfx[i].name) continue;
if (!S_sfx[i].name || !S_sfx[i].priority) continue;
lua_pushfstring(L, "sfx_%s", S_sfx[i].name);
lua_pushinteger(L, i);
@@ -9422,4 +9425,4 @@ void LUA_SetActionByName(void *state, const char *actiontocompare)
return;
}
}
}
}