Closed GuillaumeGomez closed 9 years ago
I don't follow you. In which way is it wrong ? It does need a NULL terminated array, that's what I'm providing.
What's wrong in this picture?
for tmp in authors.iter() {
let c_str = CString::from_slice(tmp.as_bytes());
tmp_vec.push(c_str.as_ptr());
}
Every iteration makes a CString
, puts a pointer into tmp_vec
and the CString
is then immediately destroyed.
Oh right ! Hum... That's annoying.
I plan to deal with vectors after finishing singular conversions in #220
If you have something in mind, it's perfect then. A centralized solution is really missing for this kind of stuff.
That code is still wrong though, it makes a vector of dangling pointers. I'm hoping to make a generic
glib::translate
implementation that would handle this along with other cases of passing arrays back and forth.