Skip to content

Commit 755544e

Browse files
mmetcalfe9prady9
authored andcommitted
Retain the arrays returned from Features's accessors (#68)
* Retain the arrays returned from Features's accessors
1 parent 01987e0 commit 755544e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/vision/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
extern crate libc;
22

3+
use std::mem;
34
use array::Array;
45
use defines::{AfError, HomographyType, MatchType};
56
use util::HasAfEnum;
@@ -78,8 +79,13 @@ macro_rules! feat_func_def {
7879
unsafe {
7980
let mut temp: i64 = 0;
8081
let err_val = $ffi_name(&mut temp as MutAfArray, self.feat as Feat);
82+
83+
let temp_array = Array::from(temp);
84+
let retained = temp_array.clone();
85+
unsafe { mem::forget(temp_array); }
86+
8187
match err_val {
82-
0 => Ok(Array::from(temp)),
88+
0 => Ok(retained),
8389
_ => Err(AfError::from(err_val)),
8490
}
8591
}

0 commit comments

Comments
 (0)