mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-09 04:39:24 +00:00
@@ -1,6 +1,6 @@
|
||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
||||
#![cfg_attr(feature = "allocator", feature(allocator_api))]
|
||||
#![cfg_attr(all(zalloc_rustc_nightly, feature = "allocator"), feature(allocator_api))]
|
||||
|
||||
//! Implementation of a Zeroizing Allocator, enabling zeroizing memory on deallocation.
|
||||
//! This can either be used with Box (requires nightly and the "allocator" feature) to provide the
|
||||
@@ -17,12 +17,12 @@ use zeroize::Zeroize;
|
||||
/// An allocator wrapper which zeroizes its memory on dealloc.
|
||||
pub struct ZeroizingAlloc<T>(pub T);
|
||||
|
||||
#[cfg(feature = "allocator")]
|
||||
#[cfg(all(zalloc_rustc_nightly, feature = "allocator"))]
|
||||
use core::{
|
||||
ptr::NonNull,
|
||||
alloc::{AllocError, Allocator},
|
||||
};
|
||||
#[cfg(feature = "allocator")]
|
||||
#[cfg(all(zalloc_rustc_nightly, feature = "allocator"))]
|
||||
unsafe impl<T: Allocator> Allocator for ZeroizingAlloc<T> {
|
||||
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
|
||||
self.0.allocate(layout)
|
||||
|
||||
Reference in New Issue
Block a user