New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix transfer full conversion of Atom arrays #180

Merged
merged 1 commit into from Jul 19, 2017
Jump to file or symbol
Failed to load files and symbols.
+6 −8
Diff settings

Always

Just for now

Fix transfer full conversion of Atom arrays

Instead of the original pointer, the pointer at the end of the array was
being freed.
  • Loading branch information...
sdroege committed Jul 19, 2017
commit 89bdc07161f99d4f259bfa1eb10c60c166e1e1c6
View
@@ -100,15 +100,14 @@ impl FromGlibPtrFull<ffi::GdkAtom> for Atom {
}
impl FromGlibContainerAsVec<ffi::GdkAtom, *mut ffi::GdkAtom> for Atom {
unsafe fn from_glib_none_num_as_vec(mut ptr: *mut ffi::GdkAtom, num: usize) -> Vec<Self> {
unsafe fn from_glib_none_num_as_vec(ptr: *mut ffi::GdkAtom, num: usize) -> Vec<Self> {
if num == 0 || ptr.is_null() {
return Vec::new();
}
let mut res = Vec::with_capacity(num);
for _ in 0..num {
res.push(from_glib_none(ptr::read(ptr)));
ptr = ptr.offset(1);
for i in 0..num {
res.push(from_glib_none(ptr::read(ptr.offset(i as isize))));
}
res
}
@@ -119,15 +118,14 @@ impl FromGlibContainerAsVec<ffi::GdkAtom, *mut ffi::GdkAtom> for Atom {
res
}
unsafe fn from_glib_full_num_as_vec(mut ptr: *mut ffi::GdkAtom, num: usize) -> Vec<Self> {
unsafe fn from_glib_full_num_as_vec(ptr: *mut ffi::GdkAtom, num: usize) -> Vec<Self> {
if num == 0 || ptr.is_null() {
return Vec::new();
}
let mut res = Vec::with_capacity(num);
for _ in 0..num {
res.push(from_glib_full(ptr::read(ptr)));
ptr = ptr.offset(1);
for i in 0..num {
res.push(from_glib_full(ptr::read(ptr.offset(i as isize))));
}
glib_ffi::g_free(ptr as *mut _);
res
ProTip! Use n and p to navigate between commits in a pull request.