diff options
| author | Daniel Micay <danielmicay@gmail.com> | 2014-01-17 20:45:48 -0500 |
|---|---|---|
| committer | Daniel Micay <danielmicay@gmail.com> | 2014-01-17 23:41:31 -0500 |
| commit | ae2a5ecbf600495a80ae4d99853a2ed2c8f6b5e9 (patch) | |
| tree | 699380bedd508918752bc0cfa7c8ebc91aff3ca0 /src/libstd/libc.rs | |
| parent | aa67e13498936c42581f70daaf3b6d028426dde6 (diff) | |
| download | rust-ae2a5ecbf600495a80ae4d99853a2ed2c8f6b5e9.tar.gz rust-ae2a5ecbf600495a80ae4d99853a2ed2c8f6b5e9.zip | |
handle zero-size allocations correctly
The `malloc` family of functions may return a null pointer for a zero-size allocation, which should not be interpreted as an out-of-memory error. If the implementation does not return a null pointer, then handling this will result in memory savings for zero-size types. This also switches some code to `malloc_raw` in order to maintain a centralized point for handling out-of-memory in `rt::global_heap`. Closes #11634
Diffstat (limited to 'src/libstd/libc.rs')
| -rw-r--r-- | src/libstd/libc.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libstd/libc.rs b/src/libstd/libc.rs index 9cf94e5a1b8..77ac226a7f1 100644 --- a/src/libstd/libc.rs +++ b/src/libstd/libc.rs @@ -3223,7 +3223,7 @@ pub mod funcs { pub fn strtoul(s: *c_char, endp: **c_char, base: c_int) -> c_ulong; pub fn calloc(nobj: size_t, size: size_t) -> *c_void; - pub fn malloc(size: size_t) -> *c_void; + pub fn malloc(size: size_t) -> *mut c_void; pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; pub fn free(p: *c_void); pub fn exit(status: c_int) -> !; |
