--- a/src/lua_objs.c Thu Apr 02 02:56:31 2009 +0300
+++ b/src/lua_objs.c Thu Apr 02 02:59:52 2009 +0300
@@ -510,6 +510,21 @@
char *path;
};
+static int lua_modules__gc (lua_State *L)
+{
+ struct lua_modules *lua_modules = lua_obj_get_obj(L, __func__, "spbot.modules");
+
+ // remove the modules path if it was set by us
+ if (lua_modules->path && modules_path(lua_modules->modules, NULL) == lua_modules->path)
+ modules_path(lua_modules->modules, "");
+
+ // release any strdup'd path
+ free(lua_modules->path);
+
+ // ok
+ return 0;
+}
+
static int lua_modules_path (lua_State *L)
{
struct lua_modules *lua_modules = lua_obj_get_obj(L, __func__, "spbot.modules");
@@ -577,6 +592,7 @@
}
static const struct luaL_Reg lua_modules_methods[] = {
+ { "__gc", &lua_modules__gc },
{ "path", &lua_modules_path },
{ "load", &lua_modules_load },
{ "module", &lua_modules_module },