refactor with luaL_setmetatable

This commit is contained in:
Francois Perrad 2017-03-24 11:38:41 +01:00
parent 96e2c7007a
commit 1fd4377ffc

View File

@ -193,8 +193,7 @@ static void **ll_register(lua_State *L, const char *path)
lua_pop(L, 1); lua_pop(L, 1);
plib = (void **)lua_newuserdata(L, sizeof(void *)); plib = (void **)lua_newuserdata(L, sizeof(void *));
*plib = NULL; *plib = NULL;
luaL_getmetatable(L, "_LOADLIB"); luaL_setmetatable(L, "_LOADLIB");
lua_setmetatable(L, -2);
lua_pushfstring(L, "LOADLIB: %s", path); lua_pushfstring(L, "LOADLIB: %s", path);
lua_pushvalue(L, -2); lua_pushvalue(L, -2);
lua_settable(L, LUA_REGISTRYINDEX); lua_settable(L, LUA_REGISTRYINDEX);