Skip to content
Snippets Groups Projects
Commit 79eb089e authored by Per Lindgren's avatar Per Lindgren
Browse files

single struct

parent ef2b5994
No related branches found
No related tags found
No related merge requests found
......@@ -76,11 +76,16 @@ where
for (index, value) in free.iter_mut().enumerate() {
*value = index + 1;
}
*unsafe { self.init.get_mut_unchecked() } = true;
println!("init : free {:?}", unsafe { self.free.get_mut_unchecked() });
}
fn dealloc(&self, index: usize) {
unsafe {
if !*self.init.get_mut_unchecked() {
panic!();
}
self.free.get_mut_unchecked()[index] = *self.head.get_mut_unchecked();
*self.head.get_mut_unchecked() = index;
}
......@@ -89,6 +94,9 @@ where
fn alloc(&'static self) -> Result<Box<T, S>, ()> {
unsafe {
if !*self.init.get_mut_unchecked() {
panic!();
}
let index = *self.head.get_mut_unchecked();
println!("index {}", self.head.get_mut_unchecked());
println!("head {}", self.head.get_mut_unchecked());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment