Skip to content

Commit

Permalink
Print out the error when HeapFree failures do occur
Browse files Browse the repository at this point in the history
  • Loading branch information
retep998 committed Oct 25, 2016
1 parent affc3b7 commit b3e8c4c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/liballoc_system/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ mod imp {
fn HeapAlloc(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T) -> LPVOID;
fn HeapReAlloc(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID, dwBytes: SIZE_T) -> LPVOID;
fn HeapFree(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID) -> BOOL;
fn GetLastError() -> DWORD;
}

#[repr(C)]
Expand Down Expand Up @@ -230,11 +231,11 @@ mod imp {
pub unsafe fn deallocate(ptr: *mut u8, _old_size: usize, align: usize) {
if align <= MIN_ALIGN {
let err = HeapFree(GetProcessHeap(), 0, ptr as LPVOID);
debug_assert!(err != 0);
debug_assert!(err != 0, "Failed to free heap memory: {}", GetLastError());
} else {
let header = get_header(ptr);
let err = HeapFree(GetProcessHeap(), 0, header.0 as LPVOID);
debug_assert!(err != 0);
debug_assert!(err != 0, "Failed to free heap memory: {}", GetLastError());
}
}

Expand Down

0 comments on commit b3e8c4c

Please sign in to comment.