Improve C string handling a bit

These are always going to be valid UTF-8 or things are very wrong.
This commit is contained in:
Sebastian Dröge 2017-01-23 14:34:21 +02:00
parent e2b18a91e0
commit 7a33a4177f
3 changed files with 8 additions and 6 deletions

View file

@ -108,7 +108,7 @@ impl Caps {
unsafe {
let ptr = gst_caps_to_string(self.0);
let s = CStr::from_ptr(ptr).to_string_lossy().into_owned();
let s = CStr::from_ptr(ptr).to_str().unwrap().into();
g_free(ptr);
s

View file

@ -102,8 +102,9 @@ impl Stream {
unsafe {
CStr::from_ptr(gst_stream_get_stream_id(self.0))
.to_string_lossy()
.into_owned()
.to_str()
.unwrap()
.into()
}
}
@ -215,8 +216,9 @@ impl StreamCollection {
unsafe {
CStr::from_ptr(gst_stream_collection_get_upstream_id(self.0))
.to_string_lossy()
.into_owned()
.to_str()
.unwrap()
.into()
}
}

View file

@ -138,7 +138,7 @@ impl TagList {
unsafe {
let ptr = gst_tag_list_to_string(self.0);
let s = CStr::from_ptr(ptr).to_string_lossy().into_owned();
let s = CStr::from_ptr(ptr).to_str().unwrap().into();
g_free(ptr);
s