Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Can segfault #5
Being a bit dense above - easy to work around by keeping the doc node in scope until I've finished with it! Annoying but it works for now...
I'll also have a read through of the pugixml docs to see where / how I can set up the FFI finalizers to keep the doc around until after all the nodes have been used. Is anyone aware of any other FFI bindings that do a similar thing?
Pugixml deliberately doesn't require the nodes to be kept alive - they a single pointers that reference inside the original doc. The real solution is not to keep alive the memory that Pugixml-hs allocated, but to skip the memory allocation in the first place. As for an example of a library that follows that pattern, Hexml is the perfect example. see here, where each node points at the central document.
I was working on a patch to do the above, but then discovered even with those changes the underlying Pugixml was too slow, so went off and developed Hexml.