1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
use crate::;
/// This function is the counterpart to [`crate::alloc`].
///
/// Every pointer produced by [`crate::alloc`] or [`crate::realloc`] must eventually be
/// released with this function or [`crate::realloc`]. Unlike C's `free`, passing a null
/// pointer returns an error instead of being a no-op.
///
/// # Errors
///
/// An error is returned if a safety check fails.
///
/// # Safety
///
/// Only pointers produced by [`crate::alloc`] or [`crate::realloc`] may be freed using
/// this function; passing any other pointer causes undefined behaviour. The safety
/// checks are best-effort: any error other than `NullPtr` indicates that undefined
/// behaviour has already occurred, and the checks are performed non-atomically, so
/// concurrent misuse from another thread may go undetected. Unless `ptr` is misaligned
/// or null, **this function will dereference it**.
pub unsafe
/// Deallocates the already-validated block whose header is at `header_ptr`.
///
/// # Errors
/// - `Err(LayoutError)` if the stored size does not form a valid layout.
///
/// # Safety
/// `header_ptr` must point to the live, initialized header of a used allocation produced
/// by this crate, as returned by [`validate`].
pub unsafe