@@ -13,10 +13,28 @@ use fst::{Levenshtein,Regex};
1313/// Exposes information about errors over the ABI
1414pub struct Context {
1515 pub has_error : bool ,
16- pub error_type : * const libc:: c_char ,
17- pub error_debug : * const libc:: c_char ,
18- pub error_display : * const libc:: c_char ,
19- pub error_description : * const libc:: c_char ,
16+ pub error_type : * mut libc:: c_char ,
17+ pub error_debug : * mut libc:: c_char ,
18+ pub error_display : * mut libc:: c_char ,
19+ pub error_description : * mut libc:: c_char ,
20+ }
21+
22+ impl Context {
23+ pub fn clear ( & mut self ) {
24+ self . has_error = false ;
25+ if !self . error_type . is_null ( ) {
26+ fst_string_free ( self . error_type ) ;
27+ }
28+ if !self . error_debug . is_null ( ) {
29+ fst_string_free ( self . error_debug ) ;
30+ }
31+ if !self . error_display . is_null ( ) {
32+ fst_string_free ( self . error_display ) ;
33+ }
34+ if !self . error_description . is_null ( ) {
35+ fst_string_free ( self . error_description ) ;
36+ }
37+ }
2038}
2139
2240
@@ -43,10 +61,10 @@ pub fn get_typename<T>(_: &T) -> &'static str {
4361pub extern "C" fn fst_context_new ( ) -> * mut Context {
4462 to_raw_ptr ( Context {
4563 has_error : false ,
46- error_type : ptr:: null ( ) ,
47- error_description : ptr:: null ( ) ,
48- error_display : ptr:: null ( ) ,
49- error_debug : ptr:: null ( ) ,
64+ error_type : ptr:: null_mut ( ) ,
65+ error_description : ptr:: null_mut ( ) ,
66+ error_display : ptr:: null_mut ( ) ,
67+ error_debug : ptr:: null_mut ( ) ,
5068 } )
5169}
5270make_free_fn ! ( fst_context_free, * mut Context ) ;
0 commit comments