From ba4e23f1702996336f580312dcdc67d55ed29ae7 Mon Sep 17 00:00:00 2001 From: Josh Haberman Date: Wed, 7 Dec 2016 00:52:25 -0800 Subject: Added a few missing __gc metamethods. --- upb/bindings/lua/msg.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'upb/bindings/lua/msg.c') diff --git a/upb/bindings/lua/msg.c b/upb/bindings/lua/msg.c index e7c3f2e..d77c429 100644 --- a/upb/bindings/lua/msg.c +++ b/upb/bindings/lua/msg.c @@ -950,6 +950,12 @@ int lupb_msg_pushref(lua_State *L, int msgclass, void *msg) { return 1; } +static int lupb_msg_gc(lua_State *L) { + lupb_msg *lmsg = lupb_msg_check(L, 1); + upb_msg_uninit(lmsg->msg, lmsg->lmsgclass->layout); + return 0; +} + /* lupb_msg Public API */ /** @@ -1053,6 +1059,7 @@ static int lupb_msg_newindex(lua_State *L) { } static const struct luaL_Reg lupb_msg_mm[] = { + {"__gc", lupb_msg_gc}, {"__index", lupb_msg_index}, {"__newindex", lupb_msg_newindex}, {NULL, NULL} -- cgit v1.2.3