@@ -16,19 +16,22 @@ pub extern "C" fn pymemprofile_free_allocation(address: usize) {
16
16
memorytracking:: free_allocation ( address) ;
17
17
}
18
18
19
+ /// # Safety
20
+ /// Intended for use from C APIs, what can I say.
19
21
#[ no_mangle]
20
- pub extern "C" fn pymemprofile_start_call ( file_name : * const c_char , func_name : * const c_char ) {
21
- let name = unsafe {
22
- format ! (
23
- "{}:{}" ,
24
- CStr :: from_ptr( file_name)
25
- . to_str( )
26
- . expect( "Function name wasn't UTF-8" ) ,
27
- CStr :: from_ptr( func_name)
28
- . to_str( )
29
- . expect( "Function name wasn't UTF-8" )
30
- )
31
- } ;
22
+ pub unsafe extern "C" fn pymemprofile_start_call (
23
+ file_name : * const c_char ,
24
+ func_name : * const c_char ,
25
+ ) {
26
+ let name = format ! (
27
+ "{}:{}" ,
28
+ CStr :: from_ptr( file_name)
29
+ . to_str( )
30
+ . expect( "Function name wasn't UTF-8" ) ,
31
+ CStr :: from_ptr( func_name)
32
+ . to_str( )
33
+ . expect( "Function name wasn't UTF-8" )
34
+ ) ;
32
35
memorytracking:: start_call ( name) ;
33
36
}
34
37
@@ -42,14 +45,14 @@ pub extern "C" fn pymemprofile_reset() {
42
45
memorytracking:: reset ( ) ;
43
46
}
44
47
48
+ /// # Safety
49
+ /// Intended for use from C APIs, what can I say.
45
50
#[ no_mangle]
46
- pub extern "C" fn pymemprofile_dump_peak_to_flamegraph ( path : * const c_char ) {
47
- let path = unsafe {
48
- CStr :: from_ptr ( path)
49
- . to_str ( )
50
- . expect ( "Path wasn't UTF-8" )
51
- . to_string ( )
52
- } ;
51
+ pub unsafe extern "C" fn pymemprofile_dump_peak_to_flamegraph ( path : * const c_char ) {
52
+ let path = CStr :: from_ptr ( path)
53
+ . to_str ( )
54
+ . expect ( "Path wasn't UTF-8" )
55
+ . to_string ( ) ;
53
56
memorytracking:: dump_peak_to_flamegraph ( & path) ;
54
57
}
55
58
0 commit comments