Skip to content

Commit 88207a3

Browse files
committed
---
yaml --- r: 15201 b: refs/heads/try c: 1d25594 h: refs/heads/master i: 15199: 65c7ec1 v: v3
1 parent 2ef751d commit 88207a3

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: 5ce3d35f4170ecbf6a0efbc3cd7cdcb451c79837
5+
refs/heads/try: 1d25594657826bf9be14dee014913447851e76b4
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/libcore/vec.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export reserve;
1111
export reserve_at_least;
1212
export capacity;
1313
export len;
14+
export alloc_len;
1415
export from_fn;
1516
export from_elem;
1617
export to_mut;
@@ -153,6 +154,13 @@ pure fn len<T>(&&v: [const T]) -> uint unsafe {
153154
(**repr).fill / sys::size_of::<T>()
154155
}
155156

157+
#[doc = "Returns the number of bytes allocated for this vector"]
158+
#[inline(always)]
159+
pure fn alloc_len<T>(&&v: [const T]) -> uint unsafe {
160+
let repr: **unsafe::vec_repr = ::unsafe::reinterpret_cast(addr_of(v));
161+
(**repr).alloc
162+
}
163+
156164
#[doc = "
157165
Creates and initializes an immutable vector.
158166

branches/try/src/libstd/arena.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ impl arena for arena {
3030
start = (start + alignm1) & !alignm1;
3131
let mut end = start + n_bytes;
3232

33-
if end > vec::len(head.data) {
33+
if end > vec::alloc_len(head.data) {
3434
// Allocate a new chunk.
35-
let new_min_chunk_size = uint::max(n_bytes, vec::len(head.data));
35+
let new_min_chunk_size = uint::max(n_bytes,
36+
vec::alloc_len(head.data));
3637
head = chunk(uint::next_power_of_two(new_min_chunk_size));
3738
self.chunks = list::cons(head, @self.chunks);
3839
start = 0u;

0 commit comments

Comments
 (0)