Skip to content

Commit 9a9dc3e

Browse files
committed
---
yaml --- r: 12196 b: refs/heads/master c: b210c7a h: refs/heads/master v: v3
1 parent 1f2e08a commit 9a9dc3e

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 1d25594657826bf9be14dee014913447851e76b4
2+
refs/heads/master: b210c7ad9741fa8d560494a5686d4ac62519899f
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/libstd/arena.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,27 @@ fn arena() -> arena {
2222
}
2323

2424
impl arena for arena {
25+
fn alloc_grow(n_bytes: uint, align: uint) -> *() {
26+
// Allocate a new chunk.
27+
let mut head = list::head(self.chunks);
28+
let chunk_size = vec::alloc_len(head.data);
29+
let new_min_chunk_size = uint::max(n_bytes, chunk_size);
30+
head = chunk(uint::next_power_of_two(new_min_chunk_size));
31+
self.chunks = list::cons(head, @self.chunks);
32+
33+
ret self.alloc(n_bytes, align);
34+
}
35+
36+
#[inline(always)]
2537
fn alloc(n_bytes: uint, align: uint) -> *() {
2638
let alignm1 = align - 1u;
2739
let mut head = list::head(self.chunks);
2840

2941
let mut start = head.fill;
3042
start = (start + alignm1) & !alignm1;
31-
let mut end = start + n_bytes;
32-
43+
let end = start + n_bytes;
3344
if end > vec::alloc_len(head.data) {
34-
// Allocate a new chunk.
35-
let new_min_chunk_size = uint::max(n_bytes,
36-
vec::alloc_len(head.data));
37-
head = chunk(uint::next_power_of_two(new_min_chunk_size));
38-
self.chunks = list::cons(head, @self.chunks);
39-
start = 0u;
40-
end = n_bytes;
45+
ret self.alloc_grow(n_bytes, align);
4146
}
4247

4348
unsafe {

0 commit comments

Comments
 (0)