Skip to content

Commit 121ad1c

Browse files
committed
rename global_heap -> libc_heap
This module only contains wrappers for malloc and realloc with out-of-memory checks.
1 parent 87b658c commit 121ad1c

File tree

9 files changed

+13
-14
lines changed

9 files changed

+13
-14
lines changed

src/libcollections/hashmap.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ mod table {
4242
use std::prelude::Drop;
4343
use std::ptr;
4444
use std::ptr::RawPtr;
45-
use std::rt::global_heap;
45+
use std::rt::libc_heap;
4646
use std::intrinsics::{size_of, min_align_of, transmute};
4747
use std::intrinsics::{move_val_init, set_memory};
4848
use std::iter::{Iterator, range_step_inclusive};
@@ -243,7 +243,7 @@ mod table {
243243
keys_size, min_align_of::< K >(),
244244
vals_size, min_align_of::< V >());
245245

246-
let buffer = global_heap::malloc_raw(size) as *mut u8;
246+
let buffer = libc_heap::malloc_raw(size) as *mut u8;
247247

248248
// FIXME #13094: If malloc was not at as aligned as we expected,
249249
// our offset calculations are just plain wrong. We could support

src/libnative/io/file_win32.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ pub fn mkdir(p: &CString, _mode: io::FilePermission) -> IoResult<()> {
339339
}
340340

341341
pub fn readdir(p: &CString) -> IoResult<Vec<Path>> {
342-
use std::rt::global_heap::malloc_raw;
342+
use std::rt::libc_heap::malloc_raw;
343343

344344
fn prune(root: &CString, dirs: Vec<Path>) -> Vec<Path> {
345345
let root = unsafe { CString::new(root.with_ref(|p| p), false) };

src/librustuv/uvll.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
use libc::{size_t, c_int, c_uint, c_void, c_char, c_double};
3333
use libc::{ssize_t, sockaddr, free, addrinfo};
3434
use libc;
35-
use std::rt::global_heap::malloc_raw;
35+
use std::rt::libc_heap::malloc_raw;
3636

3737
#[cfg(test)]
3838
use libc::uintptr_t;

src/libstd/c_str.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ use str::StrSlice;
8181
use str;
8282
use slice::{ImmutableVector, MutableVector};
8383
use slice;
84-
use rt::global_heap::malloc_raw;
84+
use rt::libc_heap::malloc_raw;
8585
use raw::Slice;
8686

8787
/// The representation of a C String.

src/libstd/c_vec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ mod tests {
160160
use super::CVec;
161161
use libc;
162162
use ptr;
163-
use rt::global_heap::malloc_raw;
163+
use rt::libc_heap::malloc_raw;
164164

165165
fn malloc(n: uint) -> CVec<u8> {
166166
unsafe {
File renamed without changes.

src/libstd/rt/local_heap.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use ops::Drop;
1818
use option::{Option, None, Some};
1919
use ptr;
2020
use ptr::RawPtr;
21-
use rt::global_heap;
21+
use rt::libc_heap;
2222
use rt::local::Local;
2323
use rt::task::Task;
2424
use raw;
@@ -188,7 +188,7 @@ impl MemoryRegion {
188188
fn malloc(&mut self, size: uint) -> *mut Box {
189189
let total_size = size + AllocHeader::size();
190190
let alloc: *AllocHeader = unsafe {
191-
global_heap::malloc_raw(total_size) as *AllocHeader
191+
libc_heap::malloc_raw(total_size) as *AllocHeader
192192
};
193193

194194
let alloc: &mut AllocHeader = unsafe { cast::transmute(alloc) };
@@ -207,8 +207,7 @@ impl MemoryRegion {
207207

208208
let total_size = size + AllocHeader::size();
209209
let alloc: *AllocHeader = unsafe {
210-
global_heap::realloc_raw(orig_alloc as *mut u8,
211-
total_size) as *AllocHeader
210+
libc_heap::realloc_raw(orig_alloc as *mut u8, total_size) as *AllocHeader
212211
};
213212

214213
let alloc: &mut AllocHeader = unsafe { cast::transmute(alloc) };

src/libstd/rt/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ language and an implementation must be provided regardless of the
2626
execution environment.
2727
2828
Of foremost importance is the global exchange heap, in the module
29-
`global_heap`. Very little practical Rust code can be written without
29+
`heap`. Very little practical Rust code can be written without
3030
access to the global heap. Unlike most of `rt` the global heap is
3131
truly a global resource and generally operates independently of the
3232
rest of the runtime.
@@ -86,8 +86,8 @@ pub mod shouldnt_be_public {
8686
// Internal macros used by the runtime.
8787
mod macros;
8888

89-
// The global (exchange) heap.
90-
pub mod global_heap;
89+
/// Wrappers around malloc / realloc aborting on out-of-memory.
90+
pub mod libc_heap;
9191

9292
/// The low-level memory allocation API.
9393
pub mod heap;

src/libstd/unstable/mutex.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ mod imp {
434434

435435
#[cfg(windows)]
436436
mod imp {
437-
use rt::global_heap::malloc_raw;
437+
use rt::libc_heap::malloc_raw;
438438
use libc::{HANDLE, BOOL, LPSECURITY_ATTRIBUTES, c_void, DWORD, LPCSTR};
439439
use libc;
440440
use ptr;

0 commit comments

Comments
 (0)