diff options
| author | bors <bors@rust-lang.org> | 2014-11-02 21:22:14 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-11-02 21:22:14 +0000 |
| commit | a294b35060e069007ee46e190a6f0a19fa3eaab8 (patch) | |
| tree | 4201a43fec3a750a6fb28e1fa67beddf7a3b249c /src/libstd | |
| parent | 0c1268451b1f51fdaa31938707df8c56f08cfb31 (diff) | |
| parent | fea985a0b5008bc2f441866a80c0e3a16592eaab (diff) | |
| download | rust-a294b35060e069007ee46e190a6f0a19fa3eaab8.tar.gz rust-a294b35060e069007ee46e190a6f0a19fa3eaab8.zip | |
auto merge of #18406 : thestinger/rust/oom, r=cmr
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; |
