From 4e37a6cde2a5c898d0c7d36f0756995e547cc301 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Mon, 10 Nov 2008 17:26:24 +0100 Subject: [PATCH] luaaA: add luaA_unregister() Signed-off-by: Julien Danjou --- luaa.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/luaa.h b/luaa.h index afb0ba98e..167b56a55 100644 --- a/luaa.h +++ b/luaa.h @@ -262,7 +262,7 @@ luaA_usemetatable(lua_State *L, int idxobj, int idxfield) /** Register an Lua object. * \param L The Lua stack. * \param idx Index of the object in the stack. - * \param fct A luaA_ref address: it will be filled with the luaA_ref + * \param ref A luaA_ref address: it will be filled with the luaA_ref * registered. If the adresse point to an already registered object, it will * be unregistered. * \return Always 0. @@ -277,6 +277,17 @@ luaA_register(lua_State *L, int idx, luaA_ref *ref) return 0; } +/** Unregister a Lua object. + * \param L The Lua stack. + * \param ref A reference to an Lua object. + */ +static inline void +luaA_unregister(lua_State *L, luaA_ref *ref) +{ + luaL_unref(L, LUA_REGISTRYINDEX, *ref); + *ref = LUA_REFNIL; +} + /** Register a function. * \param L The Lua stack. * \param idx Index of the function in the stack.