-
Notifications
You must be signed in to change notification settings - Fork 54
Made hole module public for external uses. #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Moved `align_layout()` function into `HoleList`
Thanks!
I would prefer to move the |
I think that is a good idea. |
But |
Yes, I would keep them in |
Well, done! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! A few more nits, then this should be ready.
src/hole.rs
Outdated
@@ -75,17 +75,17 @@ impl HoleList { | |||
/// block is returned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you update the docs for the new second return type? For example:
"[...] Then the start address of that block and the aligned layout are returned. The automatic layout alignment is required because the HoleList
has some additional layout requirements for each memory block."
src/lib.rs
Outdated
let res = self.holes.allocate_first_fit(layout); | ||
if res.is_ok() { | ||
self.used += aligned_layout.size(); | ||
self.used += res.unwrap().1.size(); | ||
} | ||
res | ||
res.map(|tuple| tuple.0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could simplify this with a match
to avoid the unwrap()
:
match self.holes.allocate_first_fit(layout) {
Ok((ptr, aligned_layout)) => {
self.used += aligned_layout.size();
Ok(ptr)
}
Err(err) => Err(err),
}
Done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Published as v0.8.10 |
Hi Phil!
I've made hole.rs public for external uses and moved
align_layout()
function intoHoleList
.Heap
still contains thesize
and theused
counters, so it is stillHeap
that usesalign_layout
.Tell me if this is not the best solution