Fix ptr-cast-constness

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-06-02 00:30:04 +00:00 committed by June 🍓🦴
parent 050841a871
commit 38ab1083e3
2 changed files with 5 additions and 2 deletions

View file

@ -30,7 +30,10 @@ pub fn memory_stats() -> String {
let mut str = String::new();
let opaque = std::ptr::from_mut(&mut str).cast::<c_void>();
let opts_p: *const c_char = std::ffi::CString::new(opts_s).expect("cstring").into_raw() as *const c_char;
let opts_p: *const c_char = std::ffi::CString::new(opts_s)
.expect("cstring")
.into_raw()
.cast_const();
// 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

View file

@ -97,7 +97,7 @@ pub(crate) async fn stop(_server: Arc<Server>) -> Result<(), Error> {
.take()
.unwrap();
let s = std::ptr::from_ref(s) as *mut Services;
let s: *mut Services = std::ptr::from_ref(s).cast_mut();
//SAFETY: Services was instantiated in start() and leaked into the SERVICES
// global perusing as 'static for the duration of run_server(). Now we reclaim
// it to drop it before unloading the module. If this is not done there will be