News for hackers. Stuff that matters.
Re:Creating a PHP extension in Rust by pornel on Sunday April 05, 2015 @09:17AM (#9323947)
It looks like a bug indeed.

Rust is freeing the string when the function ends, since to_ptr doesn't extended its lifetime.

C seems to be getting freed memory.

AFAIK the right way is to use mem::forget to "leak" memory when giving it to C, and later have C free it by calling a Rust function that casts it back to the original type.

There are no comments on this comment yet.