From 8f17d965b29222b043d3e686c6402a416bbd2a3e Mon Sep 17 00:00:00 2001 From: strawberry Date: Sun, 28 Apr 2024 01:31:24 -0400 Subject: [PATCH] use `
` for codeblock formatting in jemalloc stats, link
 to ffi func

Signed-off-by: strawberry 
---
 Cargo.toml      | 7 ++++++-
 src/alloc/je.rs | 5 +++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index ba953a29..7036caf5 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -369,7 +369,12 @@ default = [
 backend_sqlite = ["sqlite"]
 backend_rocksdb = ["rocksdb"]
 rocksdb = ["rust-rocksdb"]
-jemalloc = ["tikv-jemalloc-sys", "tikv-jemalloc-ctl", "tikv-jemallocator", "rust-rocksdb/jemalloc"]
+jemalloc = [
+    "tikv-jemalloc-sys",
+    "tikv-jemalloc-ctl",
+    "tikv-jemallocator",
+    "rust-rocksdb/jemalloc",
+]
 jemalloc_prof = ["tikv-jemalloc-sys/profiling"]
 sqlite = ["rusqlite", "parking_lot", "thread_local"]
 systemd = ["sd-notify"]
diff --git a/src/alloc/je.rs b/src/alloc/je.rs
index b0de2d50..18f61809 100644
--- a/src/alloc/je.rs
+++ b/src/alloc/je.rs
@@ -31,11 +31,12 @@ pub(crate) fn memory_stats() -> String {
 	let opaque: *mut c_void = &mut str as *mut _ as *mut c_void;
 	let opts_p: *const c_char = std::ffi::CString::new(opts_s).expect("cstring").into_raw() as *const c_char;
 
-	// SAFETY: calls malloc_stats_print() with our string instance which must remain in this frame.
+	// SAFETY: calls malloc_stats_print() with our string instance which must remain
+	// in this frame. https://docs.rs/tikv-jemalloc-sys/latest/tikv_jemalloc_sys/fn.malloc_stats_print.html
 	unsafe { ffi::malloc_stats_print(Some(malloc_stats_cb), opaque, opts_p) };
 
 	str.truncate(MAX_LENGTH);
-	format!("{str}")
+	format!("
{str}
") } extern "C" fn malloc_stats_cb(opaque: *mut c_void, msg: *const c_char) {