You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
The current implementation doesn't properly free the returned buffer. Issues are:
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).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.
The text was updated successfully, but these errors were encountered: