-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
212 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use crate::*; | ||
|
||
/// Handle to complete deferred free in [`DeferredFreeHook`]. | ||
pub struct DeferredFreeHandle<'a, A: GlobalAlloc> { | ||
pub(crate) heap: &'a mut Heap, | ||
pub(crate) os_alloc: &'a A, | ||
} | ||
|
||
impl<A: GlobalAlloc> DeferredFreeHandle<'_, A> { | ||
/// Deallocate the block of memory at the given `ptr`. | ||
/// | ||
/// # Safety | ||
/// | ||
/// See [`GlobalAlloc::dealloc`]. | ||
pub unsafe fn free(&mut self, ptr: *mut u8) { | ||
self.heap.free(ptr, self.os_alloc); | ||
} | ||
} | ||
|
||
/// Hook to complete deferred free when the allocator needs more memory. | ||
/// See [`DeferredFreeHandle`] and [`Mimalloc::register_deferred_free`]. | ||
pub type DeferredFreeHook<A> = fn(handle: &mut DeferredFreeHandle<A>, force: bool, heartbeat: u64); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.