lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I have a lua table that I have added to the registry. I added some user date to the table and removed the data from the local stack.



    lua_rawseti(luaState, LUA_REGISTRYINDEX, index);

    lua_rawgeti(luaState, LUA_REGISTRYINDEX, index);

    lua_pushlightuserdata(luaState, this);

    lua_setfield(luaState, 1, "userdata");

    lua_pop(luaState, 1);


I then use the data in my program for a while. Eventually I am done, and want to remove the table and the user data from the Lua state by indicating they can be garbage collected. Is this all I need to do? Or do I need some special steps because of the user data in the table?

    luaL_unref(LUA_REGISTRYINDEX, index);