News for hackers. Stuff that matters.
Re:Rust FFI: Sending strings to the outside world by Veedrac on Sunday May 14, 2017 @01:04PM (#14336383)

    #[no_mangle]
    pub extern fn string_array() -> *const *const u8 {
        let v = vec![
            "Hello\0".as_ptr(),
            "World\0".as_ptr()
        ];
        v.as_ptr()
    }
This has exactly the same problem as with `CString`; the `Vec` is deallocated at function exit.
Re:Rust FFI: Sending strings to the outside world by huydotnet on Sunday May 14, 2017 @01:09PM (#14336402)
You're right. I just ran the code again, it produces something funny:

   [ '��\u0002\u0002', '8+���~', buffer: <Buffer > ]
I will update the post. Thanks for pointing it out! :D