free_sized

Function free_sized 

Source
pub unsafe extern "C" fn free_sized(
    ptr: *mut c_void,
    expected_size: usize,
) -> c_void
Expand description

The free function with an extra parameter for passing the size requested at allocation time.

This offers the same functionality as C++14 sized deallocation and can be used to implement it.

A performance-oriented allocator would use this as a performance enhancement with undefined behavior on a mismatch. Instead, this hardened allocator implementation uses it to improve security by checking that the passed size matches the allocated size.