6 Commits

Author SHA1 Message Date
Yota Toyama
f52f6dcfaf Refactor 2023-05-21 13:55:17 +10:00
Yota Toyama
3de34a77e9 Fix 2023-05-21 13:53:09 +10:00
Yota Toyama
81df12684f Fix 2023-05-21 13:52:34 +10:00
Yota Toyama
a3a13f061f Fix 2023-05-21 13:41:26 +10:00
Yota Toyama
085028a8e1 Fix 2023-05-21 13:39:31 +10:00
Yota Toyama
04f5f88b33 Fix 2023-05-21 13:38:27 +10:00
4 changed files with 16 additions and 7 deletions

View File

@@ -1,7 +1,7 @@
[package]
name = "bdwgc-alloc"
description = "impl GlobalAlloc for bdwgc"
version = "0.6.6"
version = "0.6.5"
authors = [
"swgillespie <sean.william.g@gmail.com>",
"Yota Toyama <raviqqe@gmail.com>",

View File

@@ -84,12 +84,21 @@ impl Allocator {
unsafe { GC_gcollect() }
}
pub unsafe fn register_finalizer(
pub unsafe fn register_finalizer<F: FnOnce(*mut c_void) + 'static>(
ptr: *const c_void,
finalizer: extern "C" fn(*mut c_void, *mut c_void),
client_data: *const c_void,
finalizer: F,
) {
GC_register_finalizer(ptr, finalizer, client_data, null(), null());
extern "C" fn finalize<F: FnOnce(*mut c_void)>(ptr: *mut c_void, data: *mut c_void) {
(unsafe { Box::from_raw(data as *mut F) })(ptr)
}
GC_register_finalizer(
ptr,
finalize::<F>,
Box::into_raw(Box::new(finalizer)) as *const _,
null(),
null(),
);
}
}

2
vendor/bdwgc vendored