mirror of
https://github.com/servo/servo.git
synced 2025-07-14 10:53:42 +01:00
Bug 1400754 - stylo: crash on Win64 Asan build. r=manishearth, dmajor.
* adds a hashglobe::alloc::realloc, as that was previously not implemented, copying and simplifying from liballoc_system. * routes malloc and realloc calls through hashglobe::alloc::, instead of doing it via direct 'extern "C"' calls.
This commit is contained in:
parent
e13f5a656a
commit
419642a2bd
3 changed files with 22 additions and 12 deletions
|
@ -22,7 +22,7 @@ const MIN_ALIGN: usize = 8;
|
|||
target_arch = "sparc64")))]
|
||||
const MIN_ALIGN: usize = 16;
|
||||
|
||||
pub use self::platform::{alloc, dealloc};
|
||||
pub use self::platform::{alloc, dealloc, realloc};
|
||||
|
||||
#[cfg(any(unix, target_os = "redox"))]
|
||||
mod platform {
|
||||
|
@ -47,6 +47,11 @@ mod platform {
|
|||
libc::free(ptr as *mut libc::c_void)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn realloc(ptr: *mut u8, new_size: usize) -> *mut u8 {
|
||||
libc::realloc(ptr as *mut libc::c_void, new_size) as *mut u8
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "android", target_os = "redox"))]
|
||||
#[inline]
|
||||
unsafe fn aligned_malloc(size: usize, align: usize) -> *mut u8 {
|
||||
|
@ -98,6 +103,7 @@ mod platform {
|
|||
extern "system" {
|
||||
fn GetProcessHeap() -> HANDLE;
|
||||
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;
|
||||
}
|
||||
|
@ -149,4 +155,12 @@ mod platform {
|
|||
GetLastError());
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn realloc(ptr: *mut u8, new_size: usize) -> *mut u8 {
|
||||
HeapReAlloc(GetProcessHeap(),
|
||||
0,
|
||||
ptr as LPVOID,
|
||||
new_size) as *mut u8
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue