From b437bd367a5026ce19623f36e854273a70b599ae Mon Sep 17 00:00:00 2001 From: Ferdia McKeogh Date: Fri, 26 Jan 2024 17:25:12 +0000 Subject: [PATCH] Bump dependencies, clippy suggested changes --- Cargo.toml | 4 ++-- benches/memory_allocator_benchmark.rs | 5 +---- src/lib.rs | 4 ++-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2520b26..09759d9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,8 +20,8 @@ version = "0.9.8" optional = true [dev-dependencies] -criterion = "0.3" -ctor = "0.1.23" +criterion = "0.5.1" +ctor = "0.2.6" rand = "0.8.5" rand_chacha = "0.3.1" diff --git a/benches/memory_allocator_benchmark.rs b/benches/memory_allocator_benchmark.rs index a2cbe79..0055c10 100644 --- a/benches/memory_allocator_benchmark.rs +++ b/benches/memory_allocator_benchmark.rs @@ -12,6 +12,7 @@ use alloc::alloc::GlobalAlloc; use alloc::alloc::Layout; use buddy_system_allocator::LockedHeap; use criterion::{black_box, criterion_group, criterion_main, Criterion}; +use rand::{Rng, SeedableRng}; const SMALL_SIZE: usize = 8; const LARGE_SIZE: usize = 1024 * 1024; // 1M @@ -42,10 +43,6 @@ pub fn large_alloc(heap: &LockedHeap) { pub fn mutil_thread_random_size(heap: &'static LockedHeap) { const THREAD_SIZE: usize = 10; - use rand::prelude::*; - use rand::{Rng, SeedableRng}; - use rand_chacha::ChaCha8Rng; - let mut threads = Vec::with_capacity(THREAD_SIZE); let alloc = Arc::new(heap); for i in 0..THREAD_SIZE { diff --git a/src/lib.rs b/src/lib.rs index f9dea8f..2fb10ea 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -262,7 +262,7 @@ unsafe impl GlobalAlloc for LockedHeap { .lock() .alloc(layout) .ok() - .map_or(0 as *mut u8, |allocation| allocation.as_ptr()) + .map_or(core::ptr::null_mut(), |allocation| allocation.as_ptr()) } unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { @@ -328,7 +328,7 @@ unsafe impl GlobalAlloc for LockedHeapWithRescue { inner .alloc(layout) .ok() - .map_or(0 as *mut u8, |allocation| allocation.as_ptr()) + .map_or(core::ptr::null_mut(), |allocation| allocation.as_ptr()) } } }