@@ -52,10 +52,26 @@ use uuid::Uuid;
5252/// interior null bytes and must be null terminated.
5353static PROFILER_NAME : & CStr = c"datadog-profiling" ;
5454
55+ // SAFETY: PROFILER_NAME is a valid utf8 string.
56+ static PROFILER_NAME_STR : & str = match PROFILER_NAME . to_str ( ) {
57+ Ok ( s) => s,
58+ // Panic: we own this string and it should be UTF8 (see PROFILER_NAME above).
59+ Err ( _) => panic ! ( "" ) ,
60+ } ;
61+
5562/// Version of the profiling module and zend_extension. Must not contain any
5663/// interior null bytes and must be null terminated.
5764static PROFILER_VERSION : & [ u8 ] = concat ! ( env!( "PROFILER_VERSION" ) , "\0 " ) . as_bytes ( ) ;
5865
66+ // SAFETY: PROFILER_VERSION is a byte slice that satisfies the safety requirements.
67+ static PROFILER_VERSION_STR : & str = const {
68+ match unsafe { CStr :: from_ptr ( PROFILER_VERSION . as_ptr ( ) as * const c_char ) . to_str ( ) } {
69+ Ok ( v) => v,
70+ // Panic: we own this string and it should be UTF8 (see PROFILER_VERSION above).
71+ Err ( _) => panic ! ( "PROFILER_VERSION was not a valid utf-8 string" ) ,
72+ }
73+ } ;
74+
5975/// Version ID of PHP at run-time, not the version it was built against at
6076/// compile-time. Its value is overwritten during minit.
6177static RUNTIME_PHP_VERSION_ID : AtomicU32 = AtomicU32 :: new ( zend:: PHP_VERSION_ID ) ;
@@ -130,18 +146,6 @@ static SAPI: LazyLock<Sapi> = LazyLock::new(|| {
130146 }
131147} ) ;
132148
133- // SAFETY: PROFILER_NAME is a byte slice that satisfies the safety requirements.
134- // Panic: we own this string and it should be UTF8 (see PROFILER_NAME above).
135- static PROFILER_NAME_STR : LazyLock < & ' static str > = LazyLock :: new ( || PROFILER_NAME . to_str ( ) . unwrap ( ) ) ;
136-
137- // SAFETY: PROFILER_VERSION is a byte slice that satisfies the safety requirements.
138- static PROFILER_VERSION_STR : LazyLock < & ' static str > = LazyLock :: new ( || {
139- unsafe { CStr :: from_ptr ( PROFILER_VERSION . as_ptr ( ) as * const c_char ) }
140- . to_str ( )
141- // Panic: we own this string and it should be UTF8 (see PROFILER_VERSION above).
142- . unwrap ( )
143- } ) ;
144-
145149/// The runtime ID, which is basically a universally unique "pid". This makes
146150/// it almost const, the exception being to re-initialize it from a child fork
147151/// handler. We don't yet support forking, so we use OnceCell.
@@ -618,8 +622,9 @@ extern "C" fn rinit(_type: c_int, _module_number: c_int) -> ZendResult {
618622 warn ! ( "{err}" ) ;
619623 }
620624 locals. tags = tags;
621- locals. profiling_experimental_heap_live_enabled =
622- system_settings. as_ref ( ) . profiling_experimental_heap_live_enabled
625+ locals. profiling_experimental_heap_live_enabled = system_settings
626+ . as_ref ( )
627+ . profiling_experimental_heap_live_enabled
623628 && config:: profiling_experimental_heap_live_enabled_current ( ) ;
624629 }
625630 locals. system_settings = system_settings;
0 commit comments