1
0

clippy fixes

This commit is contained in:
Kozlov Maxim
2023-09-30 15:20:46 +06:00
parent 03cd03eaea
commit 325eb718d3
3 changed files with 8 additions and 10 deletions

View File

@ -47,8 +47,8 @@ unsafe extern "system" fn done<T: AddInWrapper>(this: &mut This<0, T>) {
component.addin.done()
}
impl<T: AddInWrapper> InitDoneBaseVTable<T> {
pub fn new() -> Self {
impl<T: AddInWrapper> Default for InitDoneBaseVTable<T> {
fn default() -> Self {
Self {
dtor: 0,
#[cfg(target_family = "unix")]

View File

@ -39,7 +39,7 @@ impl MemoryManager {
size: usize,
) -> Result<NonNull<u8>, AllocationError> {
let mut ptr = ptr::null_mut::<c_void>();
let result = unsafe {
unsafe {
if (self.vptr.alloc_memory)(self, &mut ptr, size as c_ulong * 2) {
match NonNull::new(ptr as *mut u8) {
Some(ptr) => Ok(ptr),
@ -48,8 +48,7 @@ impl MemoryManager {
} else {
Err(AllocationError)
}
};
result
}
}
/// Safe wrapper around `alloc_memory` method of the MemoryManager object
@ -63,7 +62,7 @@ impl MemoryManager {
size: usize,
) -> Result<NonNull<u16>, AllocationError> {
let mut ptr = ptr::null_mut::<c_void>();
let result = unsafe {
unsafe {
if (self.vptr.alloc_memory)(self, &mut ptr, size as c_ulong * 2) {
match NonNull::new(ptr as *mut u16) {
Some(ptr) => Ok(ptr),
@ -72,8 +71,7 @@ impl MemoryManager {
} else {
Err(AllocationError)
}
};
result
}
}
pub fn free_memory(&self, ptr: &mut *mut c_void) {

View File

@ -110,8 +110,8 @@ pub unsafe fn create_component<T: AddInWrapper>(
component: *mut *mut c_void,
addin: T,
) -> c_long {
let vptr1 = Box::new(InitDoneBaseVTable::new());
let vptr2 = Box::new(LanguageExtenderBaseVTable::default());
let vptr1 = Box::<InitDoneBaseVTable<T>>::default();
let vptr2 = Box::<LanguageExtenderBaseVTable<T>>::default();
let vptr3 = Box::new(LocaleBaseVTable {
dtor: 0,
#[cfg(target_family = "unix")]