Skip to content

Commit 475df91

Browse files
committed
Remove unsafe block
1 parent 2106351 commit 475df91

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

library/std/src/sys/windows/alloc.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,23 +71,21 @@ unsafe impl GlobalAlloc for System {
7171
c::HeapFree(c::GetProcessHeap(), 0, header.0 as c::LPVOID)
7272
}
7373
};
74-
debug_assert!(err != 0, "Failed to free heap memory: {}", c::GetLastError());
74+
debug_assert!(err != 0, "Failed to free heap memory: {}", unsafe {c::GetLastError()});
7575
}
7676

7777
#[inline]
7878
unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 {
79-
unsafe {
80-
if layout.align() <= MIN_ALIGN {
81-
// SAFETY: HeapReAlloc is safe if ptr was allocated by this allocator
82-
// and new_size is not 0.
83-
unsafe {
84-
c::HeapReAlloc(c::GetProcessHeap(), 0, ptr as c::LPVOID, new_size) as *mut u8
85-
}
86-
} else {
87-
// SAFETY: The safety contract for `realloc_fallback` must be upheld by the caller
88-
unsafe {
89-
realloc_fallback(self, ptr, layout, new_size)
90-
}
79+
if layout.align() <= MIN_ALIGN {
80+
// SAFETY: HeapReAlloc is safe if ptr was allocated by this allocator
81+
// and new_size is not 0.
82+
unsafe {
83+
c::HeapReAlloc(c::GetProcessHeap(), 0, ptr as c::LPVOID, new_size) as *mut u8
84+
}
85+
} else {
86+
// SAFETY: The safety contract for `realloc_fallback` must be upheld by the caller
87+
unsafe {
88+
realloc_fallback(self, ptr, layout, new_size)
9189
}
9290
}
9391
}

0 commit comments

Comments
 (0)