From fe09d3576ada9918f55431298c5d9a099e690761 Mon Sep 17 00:00:00 2001 From: ame Date: Thu, 12 Jun 2025 13:57:51 -0500 Subject: rewrite mimetype parsing --- src/reg.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/reg.c') diff --git a/src/reg.c b/src/reg.c index 9393aa4..b0ea080 100644 --- a/src/reg.c +++ b/src/reg.c @@ -12,7 +12,12 @@ int luaopen_lullaby_##name (lua_State* L){\ luaL_register(L, #name, name##_function_list);\ int tidx = lua_gettop(L);\ - i_config_metatable(L, name##_config);\ + int idx = i_config_metatable(L, name##_config);\ + lua_pushvalue(L, idx);\ + lua_getmetatable(L, -1);\ + int midx = lua_gettop(L);\ + luaI_tsetcf(L, midx, "__gc", clean_lullaby_##name);\ + lua_setmetatable(L, idx);\ lua_settop(L, tidx);\ return 1;\ } @@ -29,7 +34,7 @@ open_common(test); lua_pushstring(L, #name);\ luaopen_lullaby_##name(L);\ lua_settable(L, T); - + int luaopen_lullaby(lua_State* L) { lua_newtable(L); @@ -42,7 +47,7 @@ int luaopen_lullaby(lua_State* L) { push(top, net); push(top, thread); push(top, test); - luaI_tsets(L, top, "version", GIT_COMMIT) + luaI_tsets(L, top, "version", GIT_COMMIT); lua_settop(L, top); return 1; -- cgit v1.2.3