@@ -23,6 +23,7 @@ use rt::local::Local;
23
23
use rt:: task:: Task ;
24
24
use unstable:: raw;
25
25
use vec:: ImmutableVector ;
26
+ use vec_ng:: Vec ;
26
27
27
28
// This has no meaning with out rtdebug also turned on.
28
29
#[ cfg( rtdebug) ]
@@ -33,7 +34,7 @@ static MAGIC: u32 = 0xbadc0ffe;
33
34
pub type Box = raw:: Box < ( ) > ;
34
35
35
36
pub struct MemoryRegion {
36
- priv allocations : ~ [ * AllocHeader ] ,
37
+ priv allocations : Vec < * AllocHeader > ,
37
38
priv live_allocations : uint ,
38
39
}
39
40
@@ -48,7 +49,7 @@ impl LocalHeap {
48
49
#[ inline]
49
50
pub fn new ( ) -> LocalHeap {
50
51
let region = MemoryRegion {
51
- allocations : ~ [ ] ,
52
+ allocations : Vec :: new ( ) ,
52
53
live_allocations : 0 ,
53
54
} ;
54
55
LocalHeap {
@@ -248,8 +249,8 @@ impl MemoryRegion {
248
249
fn release ( & mut self , alloc : & AllocHeader ) {
249
250
alloc. assert_sane ( ) ;
250
251
if TRACK_ALLOCATIONS > 1 {
251
- rtassert ! ( self . allocations[ alloc. index] == alloc as * AllocHeader ) ;
252
- self . allocations [ alloc. index ] = ptr:: null ( ) ;
252
+ rtassert ! ( self . allocations. as_slice ( ) [ alloc. index] == alloc as * AllocHeader ) ;
253
+ self . allocations . as_mut_slice ( ) [ alloc. index ] = ptr:: null ( ) ;
253
254
}
254
255
}
255
256
#[ cfg( not( rtdebug) ) ]
@@ -260,8 +261,8 @@ impl MemoryRegion {
260
261
fn update ( & mut self , alloc : & mut AllocHeader , orig : * AllocHeader ) {
261
262
alloc. assert_sane ( ) ;
262
263
if TRACK_ALLOCATIONS > 1 {
263
- rtassert ! ( self . allocations[ alloc. index] == orig) ;
264
- self . allocations [ alloc. index ] = & * alloc as * AllocHeader ;
264
+ rtassert ! ( self . allocations. as_slice ( ) [ alloc. index] == orig) ;
265
+ self . allocations . as_mut_slice ( ) [ alloc. index ] = & * alloc as * AllocHeader ;
265
266
}
266
267
}
267
268
#[ cfg( not( rtdebug) ) ]
@@ -274,7 +275,7 @@ impl Drop for MemoryRegion {
274
275
if self . live_allocations != 0 {
275
276
rtabort ! ( "leaked managed memory ({} objects)" , self . live_allocations) ;
276
277
}
277
- rtassert ! ( self . allocations. iter( ) . all( |s| s. is_null( ) ) ) ;
278
+ rtassert ! ( self . allocations. as_slice ( ) . iter( ) . all( |s| s. is_null( ) ) ) ;
278
279
}
279
280
}
280
281
0 commit comments