[Dev-luatex] The hpack_filter callback

Jonathan Sauer Jonathan.Sauer at silverstroke.com
Tue Apr 29 14:44:51 CEST 2008


Hello,

> >>               print (v.width / 65535)
> >>               % next two lines prevent memory leaks
> >>               v.list = nil
> > 
> > I don't quite understand why this is necessary. Since node.hpack
> > creates a new node list, why should this list not be freed by
> > node.free?
> 
> Because it is also still present in the paragraph. If you do
> not clear the list item, you will get a double-free error later
> on in the best case scenario. In the worst case the nodes have
> been reallocated already, and the paragraph contains garbage,
> potentially resulting in a crash.

Ah, now I understand: node.hpack creates a new node list that
*contains* the original node list.

Maybe this could be noted in the manual: "Note that the new hlist
still references the original node list, so if one wishes to only
free the new hlist, the following code must be used to avoid
deallocating the original list as well:

  hlist.list = nil
  node.free(hlist)


> Best wishes,
> Taco

Jonathan



More information about the dev-luatex mailing list