refactor: reduce the scope of unsafe in dc_context_unref()

This commit is contained in:
link2xt
2026-08-02 17:09:56 +00:00
committed by l
parent 21e08d7e95
commit 057d6c0c5e
+1 -3
View File
@@ -194,13 +194,11 @@ pub unsafe extern "C" fn dc_context_is_open(context: *mut dc_context_t) -> libc:
/// This function releases the memory of the `dc_context_t` structure. /// This function releases the memory of the `dc_context_t` structure.
#[unsafe(no_mangle)] #[unsafe(no_mangle)]
pub unsafe extern "C" fn dc_context_unref(context: *mut dc_context_t) { pub unsafe extern "C" fn dc_context_unref(context: *mut dc_context_t) {
unsafe {
if context.is_null() { if context.is_null() {
eprintln!("ignoring careless call to dc_context_unref()"); eprintln!("ignoring careless call to dc_context_unref()");
return; return;
} }
drop(Box::from_raw(context)); drop(unsafe { Box::from_raw(context) });
}
} }
#[unsafe(no_mangle)] #[unsafe(no_mangle)]