rename global_heap
-> libc_heap
This module only contains wrappers for malloc and realloc with out-of-memory checks.
This commit is contained in:
parent
87b658cf72
commit
121ad1cb7d
@ -42,7 +42,7 @@ mod table {
|
||||
use std::prelude::Drop;
|
||||
use std::ptr;
|
||||
use std::ptr::RawPtr;
|
||||
use std::rt::global_heap;
|
||||
use std::rt::libc_heap;
|
||||
use std::intrinsics::{size_of, min_align_of, transmute};
|
||||
use std::intrinsics::{move_val_init, set_memory};
|
||||
use std::iter::{Iterator, range_step_inclusive};
|
||||
@ -243,7 +243,7 @@ mod table {
|
||||
keys_size, min_align_of::< K >(),
|
||||
vals_size, min_align_of::< V >());
|
||||
|
||||
let buffer = global_heap::malloc_raw(size) as *mut u8;
|
||||
let buffer = libc_heap::malloc_raw(size) as *mut u8;
|
||||
|
||||
// FIXME #13094: If malloc was not at as aligned as we expected,
|
||||
// our offset calculations are just plain wrong. We could support
|
||||
|
@ -339,7 +339,7 @@ pub fn mkdir(p: &CString, _mode: io::FilePermission) -> IoResult<()> {
|
||||
}
|
||||
|
||||
pub fn readdir(p: &CString) -> IoResult<Vec<Path>> {
|
||||
use std::rt::global_heap::malloc_raw;
|
||||
use std::rt::libc_heap::malloc_raw;
|
||||
|
||||
fn prune(root: &CString, dirs: Vec<Path>) -> Vec<Path> {
|
||||
let root = unsafe { CString::new(root.with_ref(|p| p), false) };
|
||||
|
@ -32,7 +32,7 @@
|
||||
use libc::{size_t, c_int, c_uint, c_void, c_char, c_double};
|
||||
use libc::{ssize_t, sockaddr, free, addrinfo};
|
||||
use libc;
|
||||
use std::rt::global_heap::malloc_raw;
|
||||
use std::rt::libc_heap::malloc_raw;
|
||||
|
||||
#[cfg(test)]
|
||||
use libc::uintptr_t;
|
||||
|
@ -81,7 +81,7 @@ use str::StrSlice;
|
||||
use str;
|
||||
use slice::{ImmutableVector, MutableVector};
|
||||
use slice;
|
||||
use rt::global_heap::malloc_raw;
|
||||
use rt::libc_heap::malloc_raw;
|
||||
use raw::Slice;
|
||||
|
||||
/// The representation of a C String.
|
||||
|
@ -160,7 +160,7 @@ mod tests {
|
||||
use super::CVec;
|
||||
use libc;
|
||||
use ptr;
|
||||
use rt::global_heap::malloc_raw;
|
||||
use rt::libc_heap::malloc_raw;
|
||||
|
||||
fn malloc(n: uint) -> CVec<u8> {
|
||||
unsafe {
|
||||
|
@ -18,7 +18,7 @@ use ops::Drop;
|
||||
use option::{Option, None, Some};
|
||||
use ptr;
|
||||
use ptr::RawPtr;
|
||||
use rt::global_heap;
|
||||
use rt::libc_heap;
|
||||
use rt::local::Local;
|
||||
use rt::task::Task;
|
||||
use raw;
|
||||
@ -188,7 +188,7 @@ impl MemoryRegion {
|
||||
fn malloc(&mut self, size: uint) -> *mut Box {
|
||||
let total_size = size + AllocHeader::size();
|
||||
let alloc: *AllocHeader = unsafe {
|
||||
global_heap::malloc_raw(total_size) as *AllocHeader
|
||||
libc_heap::malloc_raw(total_size) as *AllocHeader
|
||||
};
|
||||
|
||||
let alloc: &mut AllocHeader = unsafe { cast::transmute(alloc) };
|
||||
@ -207,8 +207,7 @@ impl MemoryRegion {
|
||||
|
||||
let total_size = size + AllocHeader::size();
|
||||
let alloc: *AllocHeader = unsafe {
|
||||
global_heap::realloc_raw(orig_alloc as *mut u8,
|
||||
total_size) as *AllocHeader
|
||||
libc_heap::realloc_raw(orig_alloc as *mut u8, total_size) as *AllocHeader
|
||||
};
|
||||
|
||||
let alloc: &mut AllocHeader = unsafe { cast::transmute(alloc) };
|
||||
|
@ -26,7 +26,7 @@ language and an implementation must be provided regardless of the
|
||||
execution environment.
|
||||
|
||||
Of foremost importance is the global exchange heap, in the module
|
||||
`global_heap`. Very little practical Rust code can be written without
|
||||
`heap`. Very little practical Rust code can be written without
|
||||
access to the global heap. Unlike most of `rt` the global heap is
|
||||
truly a global resource and generally operates independently of the
|
||||
rest of the runtime.
|
||||
@ -86,8 +86,8 @@ pub mod shouldnt_be_public {
|
||||
// Internal macros used by the runtime.
|
||||
mod macros;
|
||||
|
||||
// The global (exchange) heap.
|
||||
pub mod global_heap;
|
||||
/// Wrappers around malloc / realloc aborting on out-of-memory.
|
||||
pub mod libc_heap;
|
||||
|
||||
/// The low-level memory allocation API.
|
||||
pub mod heap;
|
||||
|
@ -434,7 +434,7 @@ mod imp {
|
||||
|
||||
#[cfg(windows)]
|
||||
mod imp {
|
||||
use rt::global_heap::malloc_raw;
|
||||
use rt::libc_heap::malloc_raw;
|
||||
use libc::{HANDLE, BOOL, LPSECURITY_ATTRIBUTES, c_void, DWORD, LPCSTR};
|
||||
use libc;
|
||||
use ptr;
|
||||
|
Loading…
Reference in New Issue
Block a user