Skip to content

Retain the arrays returned from Features's accessors #68

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

Merged
merged 2 commits into from
Apr 23, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/vision/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
extern crate libc;

use std::mem;
use array::Array;
use defines::{AfError, HomographyType, MatchType};
use util::HasAfEnum;
Expand Down Expand Up @@ -78,8 +79,13 @@ macro_rules! feat_func_def {
unsafe {
let mut temp: i64 = 0;
let err_val = $ffi_name(&mut temp as MutAfArray, self.feat as Feat);

let temp_array = Array::from(temp);
let retained = temp_array.clone();
unsafe { mem::forget(temp_array); }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just changed the implementation based on your suggestion.
Using mem::forget here feels like a bit of a hack, but doing it this way doesn't require touching other files.


match err_val {
0 => Ok(Array::from(temp)),
0 => Ok(retained),
_ => Err(AfError::from(err_val)),
}
}
Expand Down