Skip to content
This repository was archived by the owner on Mar 27, 2024. It is now read-only.

Commit 25acc3d

Browse files
m-hilgendorfcrsaracco
authored andcommitted
replaced mem::uninitialized with mem::MaybeUninit, added (#112)
\#[allow(clippy::suspicous_map)] for a suspicious use of map
1 parent 7ffe280 commit 25acc3d

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

Diff for: src/buffer.rs

+1
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ impl SendEventBuffer {
448448

449449
#[inline(always)]
450450
fn store_events<T: IntoIterator<Item = U>, U: WriteIntoPlaceholder>(&mut self, events: T) {
451+
#[allow(clippy::suspicious_map)]
451452
let count = events
452453
.into_iter()
453454
.zip(self.api_events.iter_mut())

Diff for: src/host.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
33
use num_traits::Float;
44

5+
use libloading::Library;
56
use std::cell::UnsafeCell;
67
use std::error::Error;
78
use std::ffi::CString;
9+
use std::mem::MaybeUninit;
10+
use std::os::raw::c_void;
811
use std::path::Path;
912
use std::sync::{Arc, Mutex};
10-
use std::{fmt, mem, ptr, slice};
11-
12-
use libloading::Library;
13-
use std::os::raw::c_void;
13+
use std::{fmt, ptr, slice};
1414

1515
use api::consts::*;
1616
use api::{self, AEffect, PluginFlags, PluginMain, Supported, TimeInfo};
@@ -563,21 +563,21 @@ impl Plugin for PluginInstance {
563563
}
564564

565565
fn get_input_info(&self, input: i32) -> ChannelInfo {
566-
let mut props = unsafe { mem::uninitialized() };
567-
let ptr = &mut props as *mut api::ChannelProperties as *mut c_void;
566+
let mut props: MaybeUninit<api::ChannelProperties> = MaybeUninit::uninit();
567+
let ptr = props.as_mut_ptr() as *mut c_void;
568568

569569
self.dispatch(plugin::OpCode::GetInputInfo, input, 0, ptr, 0.0);
570570

571-
ChannelInfo::from(props)
571+
ChannelInfo::from(unsafe { props.assume_init() })
572572
}
573573

574574
fn get_output_info(&self, output: i32) -> ChannelInfo {
575-
let mut props = unsafe { mem::uninitialized() };
576-
let ptr = &mut props as *mut api::ChannelProperties as *mut c_void;
575+
let mut props: MaybeUninit<api::ChannelProperties> = MaybeUninit::uninit();
576+
let ptr = props.as_mut_ptr() as *mut c_void;
577577

578578
self.dispatch(plugin::OpCode::GetOutputInfo, output, 0, ptr, 0.0);
579579

580-
ChannelInfo::from(props)
580+
ChannelInfo::from(unsafe { props.assume_init() })
581581
}
582582

583583
fn get_parameter_object(&mut self) -> Arc<dyn PluginParameters> {

0 commit comments

Comments
 (0)