| alloc | Heap allocation. T comes from the variable the result is assigned to
('?&heap char buf = std::alloc(64UL);'); 'unsigned char' for untyped bytes.
Sizes are in bytes. |
| alloc_zeroed | |
| dealloc | |
| realloc_buf | |
| checked_mul_size | Multiply two allocation-size factors (typically an element count and an
element size) and abort with a diagnostic instead of silently wrapping
if the product overflows unsigned long — the classic "count * elem_size"
integer-overflow-to-undersized-allocation bug. Use this instead of a
bare '*' anywhere the multiplicands aren't both compile-time constants
small enough to prove can't overflow. |
| checked_add_size | Same idea as checked_mul_size but for addition (e.g. summing several
fields' sizes into one combined allocation) -- abort instead of silently
wrapping if the sum overflows unsigned long. |
| safe_memcpy | Element-wise copies between slices: min(dst.len, src.len) elements, the
count returned. safe_memmove allows dst and src to overlap. |
| safe_memmove | |
| safe_memset | Sets every byte of s's elements to val (memset). |
| safe_memset_obj | The same, for one object: safe_memset_obj(&ev, 0) clears a struct. |
| safe_memcmp | Byte-wise comparison (memcmp) of a and b over their common length; when
that prefix is equal, the shorter slice compares less. |
| mem_align_up | Round addr up to the next multiple of align (must be power of two). |
| mem_align_down | Round addr down to the previous multiple of align. |
| mem_is_aligned | Return 1 if addr is aligned to align bytes. |
| mem_prefetch | Software prefetch hint (maps to __builtin_prefetch on GCC/Clang, no-op elsewhere).
locality: 0=no temporal, 1=low, 2=moderate, 3=high |
| mem_zero_secure | Zero s (all its elements' bytes) with volatile stores the optimizer can't
remove (for secrets); mem_zero_secure_obj zeroes one object the same way. |
| mem_zero_secure_obj | |
| mem_clflush | Write back and invalidate the cache line containing addr (x86 CLFLUSH,
AArch64 DC CIVAC; a no-op on other targets). |
| mem_align_ptr | Round a reference up to the next align-byte boundary (power of two). |
| mem_fits_page | Check if size bytes fit within a page (4096 bytes) from addr. |