Skip to content
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

Support shrink to empty #6817

Merged
merged 3 commits into from
Dec 1, 2024
Merged

Support shrink to empty #6817

merged 3 commits into from
Dec 1, 2024

Conversation

tustvold
Copy link
Contributor

Which issue does this PR close?

Closes #.

Rationale for this change

Follow up to #6790

What changes are included in this PR?

Are there any user-facing changes?

@github-actions github-actions bot added the arrow Changes to the arrow crate label Nov 29, 2024
@alamb
Copy link
Contributor

alamb commented Dec 1, 2024

FYI @emilk

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thanks @tustvold -- makes sense to me

@@ -468,7 +468,7 @@ impl MutableBuffer {
}

#[inline]
fn dangling_ptr() -> NonNull<u8> {
pub(crate) fn dangling_ptr() -> NonNull<u8> {
// SAFETY: ALIGNMENT is a non-zero usize which is then casted
// to a *mut T. Therefore, `ptr` is not null and the conditions for
Copy link
Contributor

Choose a reason for hiding this comment

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

Not introduced in this PR, but this function isn't generic, so I am not sure what *mut T is talking about

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 think this is a copy-pasta from NonNull::dangling

@@ -468,7 +468,7 @@ impl MutableBuffer {
}

#[inline]
fn dangling_ptr() -> NonNull<u8> {
pub(crate) fn dangling_ptr() -> NonNull<u8> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest adding some some comments about this function given its name.

Specifically, that it returns a valid, u8 pointer that is valid for the entire life of the process. Suitable for allocations of 0 length.

I realize it wasn't introduced in this PR, but the name is confusing to me -- Maybe calling it arbtrary_ptr() or something would be less confusing 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah dangling is an odd name, but is based on what the standard library calls it. I have added some docs to this effect

@tustvold tustvold merged commit 7247e6b into apache:main Dec 1, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants