mirror of
https://github.com/lua/lua
synced 2026-09-29 04:35:58 +03:00
table.pack was locking last result, avoiding its collection
This commit is contained in:
parent
b678f246a4
commit
193ce46970
1 changed files with 3 additions and 1 deletions
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: ltablib.c,v 1.52 2009/12/18 16:53:12 roberto Exp roberto $
|
||||
** $Id: ltablib.c,v 1.53 2009/12/28 16:30:31 roberto Exp roberto $
|
||||
** Library for Table Manipulation
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
|
@ -178,6 +178,8 @@ static int pack (lua_State *L) {
|
|||
for (; top >= 1; top--) /* assign elements */
|
||||
lua_rawseti(L, LUA_ENVIRONINDEX, top);
|
||||
lua_pushvalue(L, LUA_ENVIRONINDEX); /* return new table */
|
||||
/* remove new table from environment to allow its later collection */
|
||||
lua_copy(L, LUA_REGISTRYINDEX, LUA_ENVIRONINDEX);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue