#[fast_ffi]
unsafe fn malloc(size: size_t) -> *c_void;
#[fast_ffi]
- unsafe fn realloc(p: *c_void, size: size_t) -> *c_void;
+ unsafe fn realloc(p: *mut c_void, size: size_t) -> *mut c_void;
#[fast_ffi]
unsafe fn free(p: *c_void);
unsafe fn abort() -> !;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use libc::{c_char, c_void, size_t, uintptr_t, free, malloc};
+use libc::{c_char, c_void, size_t, uintptr_t, free, malloc, realloc};
use managed::raw::{BoxHeaderRepr, BoxRepr};
use unstable::intrinsics::TyDesc;
use sys::size_of;
}
/// A wrapper around libc::malloc, aborting on out-of-memory
+#[inline]
pub unsafe fn malloc_raw(size: uint) -> *c_void {
let p = malloc(size as size_t);
if p.is_null() {
p
}
+/// A wrapper around libc::realloc, aborting on out-of-memory
+#[inline]
+pub unsafe fn realloc_raw(ptr: *mut c_void, size: uint) -> *mut c_void {
+ let p = realloc(ptr, size as size_t);
+ if p.is_null() {
+ // we need a non-allocating way to print an error here
+ abort();
+ }
+ p
+}
+
// FIXME #4942: Make these signatures agree with exchange_alloc's signatures
#[cfg(stage0, not(test))]
#[lang="exchange_malloc"]