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

Commit

Permalink
replaced mem::uninitialized with mem::MaybeUninit, added (#112)
Browse files Browse the repository at this point in the history
\#[allow(clippy::suspicous_map)] for a suspicious use of map
  • Loading branch information
m-hilgendorf authored and crsaracco committed Nov 8, 2019
1 parent 7ffe280 commit 25acc3d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ impl SendEventBuffer {

#[inline(always)]
fn store_events<T: IntoIterator<Item = U>, U: WriteIntoPlaceholder>(&mut self, events: T) {
#[allow(clippy::suspicious_map)]
let count = events
.into_iter()
.zip(self.api_events.iter_mut())
Expand Down
20 changes: 10 additions & 10 deletions src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
use num_traits::Float;

use libloading::Library;
use std::cell::UnsafeCell;
use std::error::Error;
use std::ffi::CString;
use std::mem::MaybeUninit;
use std::os::raw::c_void;
use std::path::Path;
use std::sync::{Arc, Mutex};
use std::{fmt, mem, ptr, slice};

use libloading::Library;
use std::os::raw::c_void;
use std::{fmt, ptr, slice};

use api::consts::*;
use api::{self, AEffect, PluginFlags, PluginMain, Supported, TimeInfo};
Expand Down Expand Up @@ -563,21 +563,21 @@ impl Plugin for PluginInstance {
}

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

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

ChannelInfo::from(props)
ChannelInfo::from(unsafe { props.assume_init() })
}

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

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

ChannelInfo::from(props)
ChannelInfo::from(unsafe { props.assume_init() })
}

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

0 comments on commit 25acc3d

Please sign in to comment.