Open
Description
The current implementation doesn't properly free the returned buffer. Issues are:
- Returning a CString as-is just works by accident (and lack of type checking across language barriers), as internally a CString is just a pointer. The correct solution would be to use into_ptr, which is in Rust unstable, but not in 1.2 yet. The CString can then be free by passing it back to Rust & doing
from_ptr
on it. node-ffi
doesn't expose finalizers, making it necessary to memcpy the return value, or manually free the returned buffer once done (error prone).- CStrings returned from Rust can't be simply freed, as Rust is using jemalloc & not libc malloc.
The best solution is probably to use a Rust vector instead, and then pass that back into Rust's vec::from_raw_parts in order to free it. Alternatively, a callback API (and async parsing) could work well too, especially if the JS callback copied the buffer.
Metadata
Metadata
Assignees
Labels
No labels