File tree Expand file tree Collapse file tree 3 files changed +12
-3
lines changed Expand file tree Collapse file tree 3 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 2
2
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
3
3
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4
4
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5
- refs/heads/try: 5ce3d35f4170ecbf6a0efbc3cd7cdcb451c79837
5
+ refs/heads/try: 1d25594657826bf9be14dee014913447851e76b4
6
6
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ export reserve;
11
11
export reserve_at_least;
12
12
export capacity;
13
13
export len;
14
+ export alloc_len;
14
15
export from_fn;
15
16
export from_elem;
16
17
export to_mut;
@@ -153,6 +154,13 @@ pure fn len<T>(&&v: [const T]) -> uint unsafe {
153
154
( * * repr) . fill / sys:: size_of :: < T > ( )
154
155
}
155
156
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
+
156
164
#[ doc = "
157
165
Creates and initializes an immutable vector.
158
166
Original file line number Diff line number Diff line change @@ -30,9 +30,10 @@ impl arena for arena {
30
30
start = ( start + alignm1) & !alignm1;
31
31
let mut end = start + n_bytes;
32
32
33
- if end > vec:: len ( head. data ) {
33
+ if end > vec:: alloc_len ( head. data ) {
34
34
// 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 ) ) ;
36
37
head = chunk ( uint:: next_power_of_two ( new_min_chunk_size) ) ;
37
38
self . chunks = list:: cons ( head, @self . chunks ) ;
38
39
start = 0 u;
You can’t perform that action at this time.
0 commit comments