diff options
| author | Daniel Micay <danielmicay@gmail.com> | 2014-10-28 17:06:06 -0400 |
|---|---|---|
| committer | Daniel Micay <danielmicay@gmail.com> | 2014-11-01 19:23:20 -0400 |
| commit | fea985a0b5008bc2f441866a80c0e3a16592eaab (patch) | |
| tree | e612e8ff8f24654005783cf9628f7c37fbfcd59c /src/libstd | |
| parent | 39f90aead4ad52de1d2c50418da4d66320233d8e (diff) | |
| download | rust-fea985a0b5008bc2f441866a80c0e3a16592eaab.tar.gz rust-fea985a0b5008bc2f441866a80c0e3a16592eaab.zip | |
bubble up out-of-memory errors from liballoc
This makes the low-level allocation API suitable for use cases where out-of-memory conditions need to be handled. Closes #18292 [breaking-change]
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/c_vec.rs | 2 | ||||
| -rw-r--r-- | src/libstd/collections/hashmap/table.rs | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/src/libstd/c_vec.rs b/src/libstd/c_vec.rs index fd605bb2b5c..771184df53d 100644 --- a/src/libstd/c_vec.rs +++ b/src/libstd/c_vec.rs @@ -170,7 +170,7 @@ mod tests { fn malloc(n: uint) -> CVec<u8> { unsafe { let mem = libc::malloc(n as libc::size_t); - if mem.is_null() { panic!("out of memory") } + if mem.is_null() { ::alloc::oom() } CVec::new_with_dtor(mem as *mut u8, n, proc() { libc::free(mem as *mut libc::c_void); }) diff --git a/src/libstd/collections/hashmap/table.rs b/src/libstd/collections/hashmap/table.rs index faff68c75ff..4d73029b7b0 100644 --- a/src/libstd/collections/hashmap/table.rs +++ b/src/libstd/collections/hashmap/table.rs @@ -607,6 +607,7 @@ impl<K, V> RawTable<K, V> { "capacity overflow"); let buffer = allocate(size, malloc_alignment); + if buffer.is_null() { ::alloc::oom() } let hashes = buffer.offset(hash_offset as int) as *mut u64; |
