From 748551238451acf36a245fb2f883293149e2f0ca Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 3 Nov 2015 16:10:44 -0200 Subject: added comment and assert about dead keys --- lgc.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'lgc.c') diff --git a/lgc.c b/lgc.c index 47aa05e2..31c956fd 100644 --- a/lgc.c +++ b/lgc.c @@ -1,5 +1,5 @@ /* -** $Id: lgc.c,v 2.208 2015/11/02 16:19:29 roberto Exp roberto $ +** $Id: lgc.c,v 2.209 2015/11/02 18:48:07 roberto Exp roberto $ ** Garbage Collector ** See Copyright Notice in lua.h */ @@ -114,8 +114,13 @@ static void reallymarkobject (global_State *g, GCObject *o); /* -** if key is not marked, mark its entry as dead (therefore removing it -** from the table) +** If key is not marked, mark its entry as dead. This allows key to be +** collected, but keeps its entry in the table. A dead node is needed +** when Lua looks up for a key (it may be part of a chain) and when +** traversing a weak table (key might be removed from the table during +** traversal). Other places never manipulate dead keys, because its +** associated nil value is enough to signal that the entry is logically +** empty. */ static void removeentry (Node *n) { lua_assert(ttisnil(gval(n))); -- cgit v1.2.3-55-g6feb