emilk commented on code in PR #6790:
URL: https://github.com/apache/arrow-rs/pull/6790#discussion_r1858448486
##########
arrow-buffer/src/bytes.rs:
##########
@@ -96,6 +96,30 @@ impl Bytes {
}
}
+ /// Try to reallocate the underlying memory region to a new size (smaller
or larger).
+ ///
+ /// Only works for bytes allocated with the standard allocator.
+ /// Returns `Err` if the memory was allocated with a custom allocator,
+ /// or the call to `realloc` failed, for whatever reason.
+ /// In case of `Err`, the [`Bytes`] will remain as it was (i.e. have the
old size).
+ pub fn try_realloc(&mut self, new_len: usize) -> Result<(), ()> {
Review Comment:
I've documented why it is safe now, and while doing so found a bug where
`new_len = 0` would produce UB. That is now fixed :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]