Skip to content

skiplist: switch to alloc API #268

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

Merged
1 commit merged into from
Dec 17, 2018
Merged

skiplist: switch to alloc API #268

1 commit merged into from
Dec 17, 2018

Conversation

tobz
Copy link
Contributor

@tobz tobz commented Dec 16, 2018

This addresses #246 by removing the allocation hack that was in place before.

Signed-off-by: Toby Lawrence [email protected]

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! We just need to tweak a few things before merging.

@tobz
Copy link
Contributor Author

tobz commented Dec 16, 2018

@stjepang I think this is all set now.

@tobz
Copy link
Contributor Author

tobz commented Dec 17, 2018

Hmm, not really sure why it thinks that std::alloc doesn't exist... that's straight out of the Rust docs themselves. O_o

@ghost
Copy link

ghost commented Dec 17, 2018

It's because of these shenanigans we use to support no_std + alloc environments. You probably need use alloc::alloc instead of use std::alloc.

@tobz
Copy link
Contributor Author

tobz commented Dec 17, 2018

Ahhhh, alright. Lemme whip up the fix.

Signed-off-by: Toby Lawrence <[email protected]>
@tobz
Copy link
Contributor Author

tobz commented Dec 17, 2018

Looks like it's an unrelated crossbeam-channel failure at this point?

@ghost
Copy link

ghost commented Dec 17, 2018

That is an unrelated regression on nightly Rust: rust-lang/rust#56867

@ghost ghost merged commit 36d7e38 into crossbeam-rs:master Dec 17, 2018
let ptr = v.as_mut_ptr() as *mut Self;
mem::forget(v);
let layout = Self::get_layout(height);
let ptr = alloc(layout) as *mut Self;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to check for null and call handle_alloc_error(layout).

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, thanks for pointing this out! I'm used to Box::new() always working so the possibility of a failure didn't even cross my mind.

@tobz Would you like to submit a fix for this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this a bit of a footgun… eventually we’ll stabilize the Alloc trait with Result return types and deprecate these functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll submit a fix, yeah.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants