jhorstmann commented on code in PR #5895:
URL: https://github.com/apache/arrow-rs/pull/5895#discussion_r1644170515
##########
arrow-buffer/src/buffer/immutable.rs:
##########
@@ -71,6 +71,24 @@ impl Buffer {
}
}
+ /// Returns the offset, in bytes, of `Self::ptr` to `Self::data`
+ ///
+ /// self.ptr and self.data can be different after slicing or advancing the
buffer.
+ ///
+ /// # Safety
+ ///
+ /// This function is unsafe as it uses unsafe function `offset_from`.
Under certain
+ /// conditions, this function can cause undefined behavior. See the
documentation of
+ /// `offset_from` for more information.
+ pub unsafe fn ptr_offset(&self) -> usize {
Review Comment:
I'm wondering if this function should be `unsafe`. The `ptr` should always
be in bounds of `data`, any safe function that modifies `ptr` should uphold
that invariant. If it is not in bounds then nearly all other methods of
`Buffer` would also expose UB.
--
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]