Skip to content

Commit 559dcf9

Browse files
committed
Correct the layout in alloc_vec_with_capacity
We were including the header in the 'value_layout', which should only be the array value....
1 parent 497f64f commit 559dcf9

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

libs/simple/src/layout.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::ffi::c_void;
1515
use std::alloc::Layout;
1616

1717
use zerogc::{GcSafe, Trace};
18-
use zerogc::vec::repr::{GcVecRepr, ReallocFailedError};
18+
use zerogc::vec::repr::{GcVecRepr,};
1919

2020
use zerogc_context::field_offset;
2121
use zerogc_derive::{NullTrace, unsafe_gc_impl};
@@ -259,13 +259,6 @@ pub struct SimpleVecRepr<T: GcSafe> {
259259
marker: PhantomData<T>,
260260
}
261261
impl<T: GcSafe> SimpleVecRepr<T> {
262-
/// Get the in-memory layout for a [SimpleVecRepr],
263-
/// including its header
264-
#[inline]
265-
pub fn layout(capacity: usize) -> Layout {
266-
Layout::new::<GcVecHeader>()
267-
.extend(Layout::array::<T>(capacity).unwrap()).unwrap().0
268-
}
269262
#[inline]
270263
fn header(&self) -> *mut GcVecHeader {
271264
unsafe {

libs/simple/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ unsafe impl RawSimpleAlloc for RawSimpleCollector {
197197
}
198198
let (header, value_ptr) = context.collector().heap.allocator.alloc_layout(
199199
GcVecHeader::LAYOUT,
200-
SimpleVecRepr::<T>::layout(capacity),
200+
Layout::array::<T>(capacity).unwrap(),
201201
<T as StaticVecType>::STATIC_VEC_TYPE
202202
);
203203
let ptr = unsafe {
@@ -266,6 +266,7 @@ struct GcHeap {
266266
config: Arc<GcConfig>,
267267
threshold: AtomicUsize,
268268
allocator: SimpleAlloc,
269+
// TODO: This needs to be traced!!
269270
cached_empty_vec: Cell<Option<*mut GcVecHeader>>
270271
}
271272
impl GcHeap {

0 commit comments

Comments
 (0)