lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

I've got lists made up of LUA tables, implemented as dummy-header-node
circularly-linked-lists, with 'next' and 'prev' entries in each table
for linkage.

When I allocate a node, I 'point' the 'next' and 'prev' members at the 
node itself (effectively making it a 0-node list)

	function newNode ()
	    local node = {}; = node;
	    node.prev = node;
	    return node;

If I then add this node to a list:

	function addNode (list, node)
		node.prev = list.prev; = list; = node;
		list.prev = node;

and later remove it by unlinking it from it's peers and then setting it's
next/prev pointers to point to itself...

	function remNode (node) =; = node.prev;
		node.prev = = node;

Assuming that no other variables reference this table, will it ever be GC'ed?
or should I set the prev/next fields to nil to enable GC?
Mike Cuddy (, MC312), Programmer, Daddy, Human.
Fen's Ende Software, Redwood City, CA, USA, Earth, Sol System, Milky Way.
I remember asking why ... Let it rain, and protect us from this Cruel Sun.

       Join CAUCE: The Coalition Against Unsolicited Commercial E-mail.