Implement GlobalAlloc for System

This commit is contained in:
Simon Sapin
2018-04-03 17:51:03 +02:00
parent ba7081a033
commit eb69593f73
2 changed files with 156 additions and 139 deletions

View File

@@ -381,6 +381,10 @@ pub unsafe trait GlobalAlloc {
ptr
}
/// # Safety
///
/// `new_size`, when rounded up to the nearest multiple of `old_layout.align()`,
/// must not overflow (i.e. the rounded value must be less than `usize::MAX`).
unsafe fn realloc(&self, ptr: *mut Void, old_layout: Layout, new_size: usize) -> *mut Void {
let new_layout = Layout::from_size_align_unchecked(new_size, old_layout.align());
let new_ptr = self.alloc(new_layout);