@@ -22,22 +22,27 @@ fn arena() -> arena {
22
22
}
23
23
24
24
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) ]
25
37
fn alloc ( n_bytes : uint , align : uint ) -> * ( ) {
26
38
let alignm1 = align - 1 u;
27
39
let mut head = list:: head ( self . chunks ) ;
28
40
29
41
let mut start = head. fill ;
30
42
start = ( start + alignm1) & !alignm1;
31
- let mut end = start + n_bytes;
32
-
43
+ let end = start + n_bytes;
33
44
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 = 0 u;
40
- end = n_bytes;
45
+ ret self . alloc_grow ( n_bytes, align) ;
41
46
}
42
47
43
48
unsafe {
0 commit comments