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
use ;
/// Allocates for `layout`, aborting (rather than returning null) if the allocator fails.
///
/// # Safety
///
/// Like [`std::alloc::alloc`]: `layout` must have non-zero size. Every representation here
/// allocates a `Header` plus a trailing array, so the size is always non-zero; a zero-sized
/// `layout` is undefined behaviour, not an allocation failure. The returned block is
/// uninitialised — the caller must write it before reading.
pub unsafe
/// Grows or shrinks an allocation, aborting (rather than returning null) on failure.
///
/// # Safety
///
/// Like [`std::alloc::realloc`]: `ptr` must be a block currently allocated by the global
/// allocator with `old_layout`, and `new_layout.size()` must be non-zero. `new_layout` must
/// share `old_layout`'s alignment — `realloc` cannot change it — which is `debug_assert`ed
/// below (every representation reallocs the same header-plus-array shape, so the alignment
/// is constant). The returned block holds the old contents up to the smaller of the two
/// sizes; any growth is uninitialised.
pub unsafe
/// Frees an allocation.
///
/// # Safety
///
/// Like [`std::alloc::dealloc`]: `ptr` must be a block currently allocated by the global
/// allocator with *exactly* `layout` (the same one it was allocated with — each
/// representation recomputes it from the stored capacity, so it matches). After this the
/// caller must not use `ptr`.
pub unsafe