From f36cf676bf6f96c46c400dd10f13e87b9a259b20 Mon Sep 17 00:00:00 2001 From: Kim Altintop Date: Tue, 14 Feb 2023 17:49:27 +0100 Subject: [PATCH] Avoid MaybeUninit in OdbPackwriter, too --- src/odb.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/odb.rs b/src/odb.rs index 4092e58c0c..ab25c757fc 100644 --- a/src/odb.rs +++ b/src/odb.rs @@ -1,6 +1,5 @@ use std::io; use std::marker; -use std::mem::MaybeUninit; use std::ptr; use std::slice; @@ -162,7 +161,6 @@ impl<'repo> Odb<'repo> { /// Create stream for writing a pack file to the ODB pub fn packwriter(&self) -> Result, Error> { let mut out = ptr::null_mut(); - let progress = MaybeUninit::uninit(); let progress_cb: raw::git_indexer_progress_cb = Some(write_pack_progress_cb); let progress_payload = Box::new(OdbPackwriterCb { cb: None }); let progress_payload_ptr = Box::into_raw(progress_payload); @@ -178,7 +176,7 @@ impl<'repo> Odb<'repo> { Ok(OdbPackwriter { raw: out, - progress, + progress: Default::default(), progress_payload_ptr, }) } @@ -445,7 +443,7 @@ pub(crate) struct OdbPackwriterCb<'repo> { /// A stream to write a packfile to the ODB pub struct OdbPackwriter<'repo> { raw: *mut raw::git_odb_writepack, - progress: MaybeUninit, + progress: raw::git_indexer_progress, progress_payload_ptr: *mut OdbPackwriterCb<'repo>, } @@ -455,7 +453,7 @@ impl<'repo> OdbPackwriter<'repo> { unsafe { let writepack = &*self.raw; let res = match writepack.commit { - Some(commit) => commit(self.raw, self.progress.as_mut_ptr()), + Some(commit) => commit(self.raw, &mut self.progress), None => -1, }; @@ -489,7 +487,7 @@ impl<'repo> io::Write for OdbPackwriter<'repo> { let writepack = &*self.raw; let res = match writepack.append { - Some(append) => append(self.raw, ptr, len, self.progress.as_mut_ptr()), + Some(append) => append(self.raw, ptr, len, &mut self.progress), None => -1, };