Change the interface of placement new to take a tydesc as part of Issue #2831.
This commit is contained in:
parent
a7897b3ef3
commit
120773b2a7
7 changed files with 42 additions and 27 deletions
|
|
@ -31,11 +31,11 @@ impl arena for arena {
|
|||
head = chunk(uint::next_power_of_two(new_min_chunk_size + 1u));
|
||||
self.chunks = @cons(head, self.chunks);
|
||||
|
||||
ret self.alloc(n_bytes, align);
|
||||
ret self.alloc_inner(n_bytes, align);
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn alloc(n_bytes: uint, align: uint) -> *() {
|
||||
fn alloc_inner(n_bytes: uint, align: uint) -> *() {
|
||||
let alignm1 = align - 1u;
|
||||
let mut head = list::head(self.chunks);
|
||||
|
||||
|
|
@ -52,5 +52,13 @@ impl arena for arena {
|
|||
ret unsafe::reinterpret_cast(p);
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn alloc(tydesc: *()) -> *() {
|
||||
unsafe {
|
||||
let tydesc = tydesc as *sys::type_desc;
|
||||
self.alloc_inner((*tydesc).size, (*tydesc).align)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue