88// option. This file may not be copied, modified, or distributed
99// except according to those terms.
1010
11- use libc:: { c_char, c_void, size_t, uintptr_t, free, malloc} ;
11+ use libc:: { c_char, c_void, size_t, uintptr_t, free, malloc, realloc } ;
1212use managed:: raw:: { BoxHeaderRepr , BoxRepr } ;
1313use unstable:: intrinsics:: TyDesc ;
1414use sys:: size_of;
@@ -33,6 +33,7 @@ fn align_to(size: uint, align: uint) -> uint {
3333}
3434
3535/// A wrapper around libc::malloc, aborting on out-of-memory
36+ #[ inline]
3637pub unsafe fn malloc_raw ( size : uint ) -> * c_void {
3738 let p = malloc ( size as size_t ) ;
3839 if p. is_null ( ) {
@@ -42,6 +43,17 @@ pub unsafe fn malloc_raw(size: uint) -> *c_void {
4243 p
4344}
4445
46+ /// A wrapper around libc::realloc, aborting on out-of-memory
47+ #[ inline]
48+ pub unsafe fn realloc_raw ( ptr : * mut c_void , size : uint ) -> * mut c_void {
49+ let p = realloc ( ptr, size as size_t ) ;
50+ if p. is_null ( ) {
51+ // we need a non-allocating way to print an error here
52+ abort ( ) ;
53+ }
54+ p
55+ }
56+
4557// FIXME #4942: Make these signatures agree with exchange_alloc's signatures
4658#[ cfg( stage0, not( test) ) ]
4759#[ lang="exchange_malloc" ]
0 commit comments