I'm trying to implement prof.dump for jemalloc but I met some problems that can be generally applied to all functions that take a string argument.
The write interface usually take a &'static str as an input argument, however, the raw::write_str take a C-style string the end with \0. I can think of two solutions:
Take ffi::CStr as input. Let users pass a C-style string.
include alloc in jemalloc-ctl and convert a Rust-style "`&'static str" to a C-stype string.
Could you let me what is the best practice for this? Thanks!
I'm trying to implement
prof.dump
for jemalloc but I met some problems that can be generally applied to all functions that take a string argument.The write interface usually take a
&'static str
as an input argument, however, theraw::write_str
take a C-style string the end with\0
. I can think of two solutions:ffi::CStr
as input. Let users pass a C-style string.alloc
injemalloc-ctl
and convert a Rust-style "`&'static str" to a C-stype string.Could you let me what is the best practice for this? Thanks!