rt/core: port os::list_dir to rust ref #4812
This commit is contained in:
parent
53db6c7e2a
commit
a69a2acfba
9 changed files with 174 additions and 86 deletions
|
|
@ -41,6 +41,17 @@ pub unsafe fn malloc(td: *TypeDesc, size: uint) -> *c_void {
|
|||
return transmute(box);
|
||||
}
|
||||
}
|
||||
/**
|
||||
Thin wrapper around libc::malloc, none of the box header
|
||||
stuff in exchange_alloc::malloc
|
||||
*/
|
||||
pub unsafe fn malloc_raw(size: uint) -> *c_void {
|
||||
let p = c_malloc(size as size_t);
|
||||
if p.is_null() {
|
||||
fail!(~"Failure in malloc_raw: result ptr is null");
|
||||
}
|
||||
p
|
||||
}
|
||||
|
||||
pub unsafe fn free(ptr: *c_void) {
|
||||
let exchange_count = &mut *rust_get_exchange_count_ptr();
|
||||
|
|
@ -49,6 +60,10 @@ pub unsafe fn free(ptr: *c_void) {
|
|||
fail_unless!(ptr.is_not_null());
|
||||
c_free(ptr);
|
||||
}
|
||||
///Thin wrapper around libc::free, as with exchange_alloc::malloc_raw
|
||||
pub unsafe fn free_raw(ptr: *c_void) {
|
||||
c_free(ptr);
|
||||
}
|
||||
|
||||
fn get_box_size(body_size: uint, body_align: uint) -> uint {
|
||||
let header_size = size_of::<BoxHeaderRepr>();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue