summary refs log tree commit diff
path: root/qcow
diff options
context:
space:
mode:
Diffstat (limited to 'qcow')
-rw-r--r--qcow/src/qcow_raw_file.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/qcow/src/qcow_raw_file.rs b/qcow/src/qcow_raw_file.rs
index c178b3c..7d97b78 100644
--- a/qcow/src/qcow_raw_file.rs
+++ b/qcow/src/qcow_raw_file.rs
@@ -66,7 +66,7 @@ impl QcowRawFile {
         non_zero_flags: u64,
     ) -> io::Result<()> {
         self.file.seek(SeekFrom::Start(offset))?;
-        let mut buffer = BufWriter::new(&self.file);
+        let mut buffer = BufWriter::with_capacity(table.len() * size_of::<u64>(), &self.file);
         for addr in table {
             let val = if *addr == 0 {
                 0
@@ -91,7 +91,7 @@ impl QcowRawFile {
     /// Writes a refcount block to the file.
     pub fn write_refcount_block(&mut self, offset: u64, table: &[u16]) -> io::Result<()> {
         self.file.seek(SeekFrom::Start(offset))?;
-        let mut buffer = BufWriter::new(&self.file);
+        let mut buffer = BufWriter::with_capacity(table.len() * size_of::<u16>(), &self.file);
         for count in table {
             buffer.write_u16::<BigEndian>(*count)?;
         }