Skip to content

Commit d8dbbe0

Browse files
authored
feat(allocator): free_offset (#29)
1 parent aea6945 commit d8dbbe0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/allocator.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,15 @@ impl Allocator {
198198
pub unsafe fn free(&self, ptr: NonNull<u8>) {
199199
// SAFETY: The pointer is assumed to be valid and allocated by this allocator.
200200
let offset = unsafe { self.offset(ptr) };
201+
self.free_offset(offset);
202+
}
203+
204+
/// Free a block of memory previously allocated by this allocator.
205+
///
206+
/// # Safety
207+
/// - The `offset` must be a valid offset within the memory allocated by this allocator.
208+
/// - The `offset` must not have been freed before.
209+
pub unsafe fn free_offset(&self, offset: usize) {
201210
let allocation_indexes = self.find_allocation_indexes(offset);
202211

203212
// Check if the slab is assigned to this worker.

0 commit comments

Comments
 (0)