fix(alloc): pass NULL pointers in jemalloc notify ctls

This commit is contained in:
Jade Ellis committed 2026-11-21 01:41:17 +00:00
1 parent 806a63cb29
commit daabb53092
1 file changed
+19 -1
+19 -1
View File
@@ -390,7 +390,25 @@ where
get(&key)
}
fn notify(key: &Key) -> Result { xchg(key, ()) }
fn notify(key: &Key) -> Result {
// SAFETY: jemalloc notification ctls require `oldp`, `oldlenp`, and `newp`
// to be NULL and `newlen` to be 0 (otherwise `EPERM` is returned).
let ret = unsafe {
ffi::mallctlbymib(
key.as_ptr(),
key.len(),
ptr::null_mut(),
ptr::null_mut(),
ptr::null_mut(),
0,
)
};
if ret == 0 {
Ok(())
} else {
Err(err!("mallctl: {}", std::io::Error::from_raw_os_error(ret)))
}
}
fn set<T>(key: &Key, val: T) -> Result<T>
where