Skip to content

Commit 7613c9d

Browse files
committed
alloc: Format heap.rs to 80-char max
1 parent ad7508e commit 7613c9d

File tree

1 file changed

+39
-24
lines changed

1 file changed

+39
-24
lines changed

src/liballoc/heap.rs

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
// except according to those terms.
1010

1111
// FIXME: #13994: port to the sized deallocation API when available
12-
// FIXME: #13996: mark the `allocate` and `reallocate` return value as `noalias` and `nonnull`
12+
// FIXME: #13996: mark the `allocate` and `reallocate` return value as `noalias`
13+
// and `nonnull`
1314

1415
use core::intrinsics::{abort, cttz32};
1516
use core::option::{None, Option};
@@ -23,7 +24,8 @@ use libc::{c_char, c_int, c_void, size_t};
2324
extern {
2425
fn je_mallocx(size: size_t, flags: c_int) -> *mut c_void;
2526
fn je_rallocx(ptr: *mut c_void, size: size_t, flags: c_int) -> *mut c_void;
26-
fn je_xallocx(ptr: *mut c_void, size: size_t, extra: size_t, flags: c_int) -> size_t;
27+
fn je_xallocx(ptr: *mut c_void, size: size_t, extra: size_t,
28+
flags: c_int) -> size_t;
2729
fn je_dallocx(ptr: *mut c_void, flags: c_int);
2830
fn je_nallocx(size: size_t, flags: c_int) -> size_t;
2931
fn je_malloc_stats_print(write_cb: Option<extern "C" fn(cbopaque: *mut c_void, *c_char)>,
@@ -42,8 +44,9 @@ fn mallocx_align(a: uint) -> c_int { unsafe { cttz32(a as u32) as c_int } }
4244

4345
/// Return a pointer to `size` bytes of memory.
4446
///
45-
/// Behavior is undefined if the requested size is 0 or the alignment is not a power of 2. The
46-
/// alignment must be no larger than the largest supported page size on the platform.
47+
/// Behavior is undefined if the requested size is 0 or the alignment is not a
48+
/// power of 2. The alignment must be no larger than the largest supported page
49+
/// size on the platform.
4750
#[inline]
4851
pub unsafe fn allocate(size: uint, align: uint) -> *mut u8 {
4952
let ptr = je_mallocx(size as size_t, mallocx_align(align)) as *mut u8;
@@ -53,62 +56,73 @@ pub unsafe fn allocate(size: uint, align: uint) -> *mut u8 {
5356
ptr
5457
}
5558

56-
/// Extend or shrink the allocation referenced by `ptr` to `size` bytes of memory.
59+
/// Extend or shrink the allocation referenced by `ptr` to `size` bytes of
60+
/// memory.
5761
///
58-
/// Behavior is undefined if the requested size is 0 or the alignment is not a power of 2. The
59-
/// alignment must be no larger than the largest supported page size on the platform.
62+
/// Behavior is undefined if the requested size is 0 or the alignment is not a
63+
/// power of 2. The alignment must be no larger than the largest supported page
64+
/// size on the platform.
6065
///
61-
/// The `old_size` and `align` parameters are the parameters that were used to create the
62-
/// allocation referenced by `ptr`. The `old_size` parameter may also be the value returned by
63-
/// `usable_size` for the requested size.
66+
/// The `old_size` and `align` parameters are the parameters that were used to
67+
/// create the allocation referenced by `ptr`. The `old_size` parameter may also
68+
/// be the value returned by `usable_size` for the requested size.
6469
#[inline]
6570
#[allow(unused_variable)] // for the parameter names in the documentation
66-
pub unsafe fn reallocate(ptr: *mut u8, size: uint, align: uint, old_size: uint) -> *mut u8 {
67-
let ptr = je_rallocx(ptr as *mut c_void, size as size_t, mallocx_align(align)) as *mut u8;
71+
pub unsafe fn reallocate(ptr: *mut u8, size: uint, align: uint,
72+
old_size: uint) -> *mut u8 {
73+
let ptr = je_rallocx(ptr as *mut c_void, size as size_t,
74+
mallocx_align(align)) as *mut u8;
6875
if ptr.is_null() {
6976
abort()
7077
}
7178
ptr
7279
}
7380

74-
/// Extend or shrink the allocation referenced by `ptr` to `size` bytes of memory in-place.
81+
/// Extend or shrink the allocation referenced by `ptr` to `size` bytes of
82+
/// memory in-place.
7583
///
76-
/// Return true if successful, otherwise false if the allocation was not altered.
84+
/// Return true if successful, otherwise false if the allocation was not
85+
/// altered.
7786
///
78-
/// Behavior is undefined if the requested size is 0 or the alignment is not a power of 2. The
79-
/// alignment must be no larger than the largest supported page size on the platform.
87+
/// Behavior is undefined if the requested size is 0 or the alignment is not a
88+
/// power of 2. The alignment must be no larger than the largest supported page
89+
/// size on the platform.
8090
///
8191
/// The `old_size` and `align` parameters are the parameters that were used to
8292
/// create the allocation referenced by `ptr`. The `old_size` parameter may be
8393
/// any value in range_inclusive(requested_size, usable_size).
8494
#[inline]
8595
#[allow(unused_variable)] // for the parameter names in the documentation
86-
pub unsafe fn reallocate_inplace(ptr: *mut u8, size: uint, align: uint, old_size: uint) -> bool {
87-
je_xallocx(ptr as *mut c_void, size as size_t, 0, mallocx_align(align)) == size as size_t
96+
pub unsafe fn reallocate_inplace(ptr: *mut u8, size: uint, align: uint,
97+
old_size: uint) -> bool {
98+
je_xallocx(ptr as *mut c_void, size as size_t, 0,
99+
mallocx_align(align)) == size as size_t
88100
}
89101

90102
/// Deallocate the memory referenced by `ptr`.
91103
///
92104
/// The `ptr` parameter must not be null.
93105
///
94-
/// The `size` and `align` parameters are the parameters that were used to create the
95-
/// allocation referenced by `ptr`. The `size` parameter may also be the value returned by
96-
/// `usable_size` for the requested size.
106+
/// The `size` and `align` parameters are the parameters that were used to
107+
/// create the allocation referenced by `ptr`. The `size` parameter may also be
108+
/// the value returned by `usable_size` for the requested size.
97109
#[inline]
98110
#[allow(unused_variable)] // for the parameter names in the documentation
99111
pub unsafe fn deallocate(ptr: *mut u8, size: uint, align: uint) {
100112
je_dallocx(ptr as *mut c_void, mallocx_align(align))
101113
}
102114

103-
/// Return the usable size of an allocation created with the specified the `size` and `align`.
115+
/// Return the usable size of an allocation created with the specified the
116+
/// `size` and `align`.
104117
#[inline]
105118
pub fn usable_size(size: uint, align: uint) -> uint {
106119
unsafe { je_nallocx(size as size_t, mallocx_align(align)) as uint }
107120
}
108121

109122
/// Print implementation-defined allocator statistics.
110123
///
111-
/// These statistics may be inconsistent if other threads use the allocator during the call.
124+
/// These statistics may be inconsistent if other threads use the allocator
125+
/// during the call.
112126
#[unstable]
113127
pub fn stats_print() {
114128
unsafe {
@@ -145,7 +159,8 @@ unsafe fn exchange_free(ptr: *mut u8, size: uint, align: uint) {
145159
#[lang="closure_exchange_malloc"]
146160
#[inline]
147161
#[allow(deprecated)]
148-
unsafe fn closure_exchange_malloc(drop_glue: fn(*mut u8), size: uint, align: uint) -> *mut u8 {
162+
unsafe fn closure_exchange_malloc(drop_glue: fn(*mut u8), size: uint,
163+
align: uint) -> *mut u8 {
149164
let total_size = util::get_box_size(size, align);
150165
let p = allocate(total_size, 8);
151166

0 commit comments

Comments
 (0)