File tree 1 file changed +10
-9
lines changed
1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change 1
1
extern crate libc;
2
2
3
- use self :: libc:: { c_char, c_int } ;
3
+ use self :: libc:: c_char;
4
4
use crate :: defines:: AfError ;
5
5
use crate :: util:: { free_host, DimT , MutDimT } ;
6
6
use std:: error:: Error ;
@@ -10,7 +10,7 @@ use std::sync::RwLock;
10
10
11
11
#[ allow( dead_code) ]
12
12
extern "C" {
13
- fn af_get_last_error ( str : * mut * mut c_char , len : * mut DimT ) -> c_int ;
13
+ fn af_get_last_error ( str : * mut * mut c_char , len : * mut DimT ) ;
14
14
}
15
15
16
16
/// Signature of error handling callback function
@@ -99,14 +99,15 @@ pub fn HANDLE_ERROR(error_code: AfError) {
99
99
}
100
100
101
101
pub fn get_last_error ( ) -> String {
102
- let result: String ;
102
+ let mut result: String = String :: from ( "No Last Error" ) ;
103
+ let mut tmp: * mut c_char = :: std:: ptr:: null_mut ( ) ;
104
+ let mut len: DimT = 0 ;
103
105
unsafe {
104
- let mut tmp: * mut c_char = :: std:: ptr:: null_mut ( ) ;
105
- let mut len: DimT = 0 ;
106
- let err_val = af_get_last_error ( & mut tmp, & mut len as MutDimT ) ;
107
- HANDLE_ERROR ( AfError :: from ( err_val) ) ;
108
- result = CStr :: from_ptr ( tmp) . to_string_lossy ( ) . into_owned ( ) ;
109
- free_host ( tmp) ;
106
+ af_get_last_error ( & mut tmp, & mut len as MutDimT ) ;
107
+ if len > 0 {
108
+ result = CStr :: from_ptr ( tmp) . to_string_lossy ( ) . into_owned ( ) ;
109
+ free_host ( tmp) ;
110
+ }
110
111
}
111
112
result
112
113
}
You can’t perform that action at this time.
0 commit comments