Subject: [ruby-ffi] Re: Freeing memory allocated by underlying library (libxml dumpDocFormatMemory) |
From: Wayne Meissner |
Date: 2/5/13 4:22 PM |
To: ruby-ffi@googlegroups.com |
Hi folks!
I'm trying to figure out how i'm supposed to free memory when i get a pointer to a string buffer allocated by my underlying library.
https://github.com/phinze/xml_security/blob/ ebd1743f7ab493b6565137ace8d60a d3e5bac52b/lib/xml_security. rb#L216-L224
The docs for xmlDocDumpFormatMemory say it's my responsibility to free the allocated memory with xmlFree [1]. But if i try to call xmlFree on the ptr or the strptr i get segfaults, and MemoryPointer#free seems to not cork the leak.
Any guidance would be much appreciated,
Paul Hinze
[1] http://xmlsoft.org/html/libxml-tree.html# xmlDocDumpFormatMemory