Skip to main content

secure_dealloc

Function secure_dealloc 

Source
pub unsafe fn secure_dealloc(ptr: *mut u8, size: usize)
Expand description

Secure memory deallocation with enhanced security

Deallocates memory securely by zeroing it before deallocation. Implements secure deallocation best practices including:

  • Secure zeroing before deallocation
  • Multiple passes of zeroing for sensitive data
  • Compiler barriers to prevent optimization
  • Proper layout reconstruction for deallocation

§Arguments

  • ptr - Pointer to memory to deallocate
  • size - Size of memory to deallocate

§Safety

This function is unsafe because it:

  • Takes a raw pointer that must be valid for the given size
  • The pointer must have been allocated with the same allocator
  • The size must match the size used for allocation

§Security

This function securely deallocates memory by zeroing it first to prevent data leakage.