File tree 2 files changed +6
-8
lines changed
2 files changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -317,6 +317,11 @@ extern "C" {
317
317
#[ cfg( php7) ]
318
318
pub fn zend_register_extension ( extension : & ZendExtension , handle : * mut c_void ) -> ZendResult ;
319
319
320
+ /// Converts the `const char *` into a `zai_str`. A None as well as empty
321
+ /// strings will be converted into a string view to a static empty string
322
+ /// (single byte of null, len of 0).
323
+ pub fn zai_str_from_cstr ( cstr : * const c_char ) -> zai_str < ' static > ;
324
+
320
325
/// Converts the `zstr` into a `zai_str`. A None as well as empty
321
326
/// strings will be converted into a string view to a static empty string
322
327
/// (single byte of null, len of 0).
Original file line number Diff line number Diff line change @@ -204,14 +204,7 @@ unsafe extern "C" fn ddog_php_prof_zend_error_observer(
204
204
}
205
205
206
206
#[ cfg( zend_error_observer_80) ]
207
- let file = unsafe {
208
- let mut len = 0 ;
209
- let file = file as * const u8 ;
210
- while * file. add ( len) != 0 {
211
- len += 1 ;
212
- }
213
- std:: str:: from_utf8_unchecked ( std:: slice:: from_raw_parts ( file, len) ) . to_string ( )
214
- } ;
207
+ let file = unsafe { zend:: zai_str_from_cstr ( file) . into_string ( ) } ;
215
208
#[ cfg( not( zend_error_observer_80) ) ]
216
209
let file = unsafe { zend:: zai_str_from_zstr ( file. as_mut ( ) ) . into_string ( ) } ;
217
210
You can’t perform that action at this time.
0 commit comments