Passing argument to init - wrong example?
thejpster opened this issue · 1 comments
thejpster commented
In the example it says
unsafe { ALLOCATOR.init(_heap_start, _heap_end - _heap_start) }
As the linker gives you symbols, the address of which is the address you need (rather than the value itself), I think this should be
unsafe { ALLOCATOR.init(_heap_start as *mut usize as usize, (_heap_end as *mut usize as usize) - (_heap_start as *mut usize as usize) }
Or, you could change the API to take &mut T, and perform the calculations internally. This is what the r0
crate does.
japaric commented
The example has been fixed in v0.3.1.