The LuaTeX manual doesn't give much information on the precise details other than saying that one needs to ensure that there aren't any dangling pointers still referencing the node (location). For simple nodes that might be the case but already an adjust node made me question my understanding.
That type of node has a field
head that points to another node holding the "vadjust" vertical list. So my simple minded assumption was that if I do
local adjust = node.getfield(p, "head") -- save the vlist node.free(p)
I'm fine, but as it turned out all pointers in my code got scrambled. Instead I first had to explicitly do
node.setfield(p, "head", nil)
prior to freeing the node to prevent bad things from happening. What exactly goes wrong or what the function really does to the field value if it isn't nil I couldn't determine with trial and error.
So my question is: who can explain precisely what goes on with this command and/or where could one find out (i.e., where is its source assuming that is in a somewhat readable format)?
Another part of the question would be what happens when freeing other nodes that have similar structures, e.g., glue nodes (having a link to a glue-spec node etc)?