diff --git a/Cargo.lock b/Cargo.lock index b1f67e2a..38f88b7d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -569,7 +569,6 @@ dependencies = [ name = "wdk-alloc" version = "0.1.0" dependencies = [ - "lazy_static", "wdk-sys", ] diff --git a/crates/wdk-alloc/Cargo.toml b/crates/wdk-alloc/Cargo.toml index ec1a9ad7..9572d8d0 100644 --- a/crates/wdk-alloc/Cargo.toml +++ b/crates/wdk-alloc/Cargo.toml @@ -11,7 +11,6 @@ categories = ["memory-management", "no-std", "hardware-support"] [dependencies] wdk-sys.workspace = true -lazy_static = { version = "1.4.0", features = ["spin_no_std"] } [dev-dependencies] wdk-sys = { workspace = true, features = ["test-stubs"] } diff --git a/crates/wdk-alloc/src/lib.rs b/crates/wdk-alloc/src/lib.rs index b669d15c..02534f49 100644 --- a/crates/wdk-alloc/src/lib.rs +++ b/crates/wdk-alloc/src/lib.rs @@ -10,7 +10,6 @@ use core::alloc::{GlobalAlloc, Layout}; -use lazy_static::lazy_static; use wdk_sys::{ ntddk::{ExAllocatePool2, ExFreePool}, POOL_FLAG_NON_PAGED, @@ -19,22 +18,13 @@ use wdk_sys::{ }; pub struct WDKAllocator; -// The value of memory tags are stored in little-endian order, so it is -// convenient to reverse the order for readability in tooling(ie. Windbg) -// FIXME: replace lazy_static with std::Lazy once available: https://github.com/rust-lang/rust/issues/109736 -lazy_static! { - static ref RUST_TAG: ULONG = u32::from_ne_bytes( - #[allow(clippy::string_lit_as_bytes)] // A u8 slice is required here - "rust" - .as_bytes() - .try_into() - .expect("tag string.as_bytes() should be able to convert into [u8; 4]"), - ); -} +// The value of memory tags are stored in little-endian order, so it is +// convenient to reverse the order for readability in tooling (ie. Windbg) +const RUST_TAG: ULONG = u32::from_ne_bytes(*b"rust"); unsafe impl GlobalAlloc for WDKAllocator { unsafe fn alloc(&self, layout: Layout) -> *mut u8 { - let ptr = ExAllocatePool2(POOL_FLAG_NON_PAGED, layout.size() as SIZE_T, *RUST_TAG); + let ptr = ExAllocatePool2(POOL_FLAG_NON_PAGED, layout.size() as SIZE_T, RUST_TAG); assert!(!ptr.is_null(), "wdk-alloc failed to allocate memory."); ptr.cast() }