Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
realFlowControl committed Dec 11, 2024
1 parent b0da77f commit d8dea67
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
5 changes: 5 additions & 0 deletions profiling/src/bindings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,11 @@ extern "C" {
#[cfg(php7)]
pub fn zend_register_extension(extension: &ZendExtension, handle: *mut c_void) -> ZendResult;

/// Converts the `const char *` into a `zai_str`. A None as well as empty
/// strings will be converted into a string view to a static empty string
/// (single byte of null, len of 0).
pub fn zai_str_from_cstr(cstr: *const c_char) -> zai_str<'static>;

/// Converts the `zstr` into a `zai_str`. A None as well as empty
/// strings will be converted into a string view to a static empty string
/// (single byte of null, len of 0).
Expand Down
9 changes: 1 addition & 8 deletions profiling/src/timeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,7 @@ unsafe extern "C" fn ddog_php_prof_zend_error_observer(
}

#[cfg(zend_error_observer_80)]
let file = unsafe {
let mut len = 0;
let file = file as *const u8;
while *file.add(len) != 0 {
len += 1;
}
std::str::from_utf8_unchecked(std::slice::from_raw_parts(file, len)).to_string()
};
let file = unsafe { zend::zai_str_from_cstr(file).into_string() };
#[cfg(not(zend_error_observer_80))]
let file = unsafe { zend::zai_str_from_zstr(file.as_mut()).into_string() };

Expand Down
2 changes: 2 additions & 0 deletions zend_abstract_interface/zai_string/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

char *ZAI_STRING_EMPTY_PTR = "";

extern inline zai_str zai_str_from_cstr(const char *cstr);

extern inline zai_str zai_str_from_zstr(zend_string *zstr);

extern inline zai_string zai_string_concat3(zai_str first, zai_str second, zai_str third);
2 changes: 1 addition & 1 deletion zend_abstract_interface/zai_string/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static inline zai_str zai_str_new(const char *ptr, size_t len) {
*
* If the pointer is known to be non-null, use ZAI_STR_FROM_CSTR directly.
*/
static inline zai_str zai_str_from_cstr(const char *cstr) {
inline zai_str zai_str_from_cstr(const char *cstr) {
if (cstr) {
return (zai_str)ZAI_STR_FROM_CSTR(cstr);
}
Expand Down

0 comments on commit d8dea67

Please sign in to comment.