tikv / jemallocator

Rust allocator using jemalloc as a backend
Other
347 stars 58 forks source link

Support `prof.dump` for jemalloc-ctl. #60

Open yuhao-su opened 1 year ago

yuhao-su commented 1 year ago

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:

  1. Take ffi::CStr as input. Let users pass a C-style string.
  2. 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!

BusyJay commented 1 year ago

CStr should be used.

yuhao-su commented 1 year ago

Okay, I'll submit a pr later