44use crate :: arc_handle:: ArcHandle ;
55use crate :: profile_status:: ProfileStatus ;
66use crate :: profiles:: utf8:: Utf8Option ;
7- use crate :: profiles:: {
8- ensure_non_null_insert, ensure_non_null_out_parameter, null_profiles_dictionary,
9- } ;
7+ use crate :: profiles:: { ensure_non_null_insert, ensure_non_null_out_parameter} ;
108use crate :: ProfileError ;
119use libdd_common_ffi:: slice:: CharSlice ;
1210use libdd_profiling:: profiles:: collections:: StringRef ;
1311use libdd_profiling:: profiles:: datatypes:: {
1412 Function2 , FunctionId2 , Mapping2 , MappingId2 , ProfilesDictionary , StringId2 ,
1513} ;
14+ use std:: ffi:: CStr ;
1615
1716/// A StringId that represents the empty string.
1817/// This is always available in every string set and can be used without
@@ -47,6 +46,8 @@ pub static DDOG_PROF_STRINGID2_TRACE_ENDPOINT: StringId2 =
4746#[ no_mangle]
4847pub static DDOG_PROF_STRINGID2_SPAN_ID : StringId2 = StringId2 :: from ( StringRef :: SPAN_ID ) ;
4948
49+ const NULL_PROFILES_DICTIONARY : & CStr = c"passed a null pointer for a ProfilesDictionary" ;
50+
5051/// Allocates a new `ProfilesDictionary` and writes a handle to it in `handle`.
5152///
5253/// # Safety
@@ -107,7 +108,7 @@ pub unsafe extern "C" fn ddog_prof_ProfilesDictionary_insert_function(
107108 ensure_non_null_out_parameter ! ( function_id) ;
108109 ensure_non_null_insert ! ( function) ;
109110 ProfileStatus :: from ( || -> Result < ( ) , ProfileError > {
110- let dict = dict. ok_or ( null_profiles_dictionary ( ) ) ?;
111+ let dict = dict. ok_or ( NULL_PROFILES_DICTIONARY ) ?;
111112 let f2: Function2 = unsafe { * function } ;
112113 let id = dict. try_insert_function2 ( f2) ?;
113114 unsafe { function_id. write ( id) } ;
@@ -131,7 +132,7 @@ pub unsafe extern "C" fn ddog_prof_ProfilesDictionary_insert_mapping(
131132 ensure_non_null_out_parameter ! ( mapping_id) ;
132133 ensure_non_null_insert ! ( mapping) ;
133134 ProfileStatus :: from ( || -> Result < ( ) , ProfileError > {
134- let dict = dict. ok_or ( null_profiles_dictionary ( ) ) ?;
135+ let dict = dict. ok_or ( NULL_PROFILES_DICTIONARY ) ?;
135136 let m2 = unsafe { * mapping } ;
136137 let id = dict. try_insert_mapping2 ( m2) ?;
137138 unsafe { mapping_id. write ( id) } ;
@@ -156,7 +157,7 @@ pub unsafe extern "C" fn ddog_prof_ProfilesDictionary_insert_str(
156157) -> ProfileStatus {
157158 ensure_non_null_out_parameter ! ( string_id) ;
158159 ProfileStatus :: from ( || -> Result < ( ) , ProfileError > {
159- let dict = dict. ok_or ( null_profiles_dictionary ( ) ) ?;
160+ let dict = dict. ok_or ( NULL_PROFILES_DICTIONARY ) ?;
160161 crate :: profiles:: utf8:: insert_str ( dict. strings ( ) , byte_slice, utf8_option)
161162 . map ( |id| unsafe { string_id. write ( id. into ( ) ) } )
162163 } ( ) )
@@ -183,7 +184,7 @@ pub unsafe extern "C" fn ddog_prof_ProfilesDictionary_get_str(
183184) -> ProfileStatus {
184185 ensure_non_null_out_parameter ! ( result) ;
185186 let Some ( dict) = dict else {
186- return ProfileStatus :: from ( null_profiles_dictionary ( ) ) ;
187+ return ProfileStatus :: from ( NULL_PROFILES_DICTIONARY ) ;
187188 } ;
188189 let string_ref = StringRef :: from ( string_id) ;
189190 // SAFETY: It's not actually safe--as indicated in the docs
0 commit comments