luaa: fix memory leak in __gc

We need to wipe the ref_array.

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-05-08 09:53:20 +02:00
parent 3849e6d747
commit 43902aed69
7 changed files with 7 additions and 0 deletions

View File

@ -40,6 +40,7 @@ static int
luaA_button_gc(lua_State *L)
{
button_t *button = luaL_checkudata(L, 1, "button");
luaA_ref_array_wipe(&button->refs);
luaL_unref(globalconf.L, LUA_REGISTRYINDEX, button->press);
luaL_unref(globalconf.L, LUA_REGISTRYINDEX, button->release);
return 0;

View File

@ -51,6 +51,7 @@ static int
luaA_client_gc(lua_State *L)
{
client_t *c = luaL_checkudata(L, 1, "client");
luaA_ref_array_wipe(&c->refs);
button_array_wipe(&c->buttons);
image_unref(L, c->icon);
p_delete(&c->class);

View File

@ -28,6 +28,7 @@ static int
luaA_image_gc(lua_State *L)
{
image_t *p = luaL_checkudata(L, 1, "image");
luaA_ref_array_wipe(&p->refs);
imlib_context_set_image(p->image);
imlib_free_image();
p_delete(&p->data);

1
key.c
View File

@ -50,6 +50,7 @@ static int
luaA_key_gc(lua_State *L)
{
keyb_t *kbp = luaL_checkudata(L, 1, "key");
luaA_ref_array_wipe(&kbp->refs);
luaL_unref(globalconf.L, LUA_REGISTRYINDEX, kbp->press);
luaL_unref(globalconf.L, LUA_REGISTRYINDEX, kbp->release);
return 0;

1
tag.c
View File

@ -41,6 +41,7 @@ static int
luaA_tag_gc(lua_State *L)
{
tag_t *tag = luaL_checkudata(L, 1, "tag");
luaA_ref_array_wipe(&tag->refs);
client_array_wipe(&tag->clients);
p_delete(&tag->name);
return 0;

View File

@ -39,6 +39,7 @@ static int
luaA_wibox_gc(lua_State *L)
{
wibox_t *wibox = luaL_checkudata(L, 1, "wibox");
luaA_ref_array_wipe(&wibox->refs);
p_delete(&wibox->cursor);
simplewindow_wipe(&wibox->sw);
button_array_wipe(&wibox->buttons);

View File

@ -44,6 +44,7 @@ static int
luaA_widget_gc(lua_State *L)
{
widget_t *widget = luaL_checkudata(L, 1, "widget");
luaA_ref_array_wipe(&widget->refs);
if(widget->destructor)
widget->destructor(widget);
button_array_wipe(&widget->buttons);