jorgecarleitao commented on a change in pull request #8630:
URL: https://github.com/apache/arrow/pull/8630#discussion_r526401885



##########
File path: rust/arrow/src/buffer.rs
##########
@@ -888,6 +888,15 @@ impl MutableBuffer {
         }
         self.len += bytes.len();
     }
+
+    /// Extends the buffer by `len` with all bytes equal to `0u8`, 
incrementing its capacity if needed.
+    pub fn extend(&mut self, len: usize) {
+        let remaining_capacity = self.capacity - self.len;
+        if len > remaining_capacity {
+            self.reserve(self.len + len);

Review comment:
       `reserve`s API is to guarantee a capacity of up to the argument, and 
`extend`'s API is to increase `self.len` by `len`.
   
   If we call `self.reserve(300)`, but then increase the `len` by `256` to 
`54+256=310`, we will move the pointer past the allocated memory (310 > 300), 
no?
   




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to