zig/lib/std
Matthew Lugg dcc5e0e10e
std.heap: rework c_allocator
The main goal here was to avoid allocating padding and header space if
`malloc` already guarantees the alignment we need via `max_align_t`.
Previously, the compiler was using `std.heap.raw_c_allocator` as its GPA
in some cases depending on `std.c.max_align_t`, but that's pretty
fragile (it meant we had to encode our alignment requirements into
`src/main.zig`!). Perhaps more importantly, that solution is
unnecessarily restrictive: since Zig's `Allocator` API passes the
`Alignment` not only to `alloc`, but also to `free` etc, we are able to
use a different strategy depending on its value. So `c_allocator` can
simply compare the requested align to `Alignment.of(std.c.max_align_t)`,
and use a raw `malloc` call (no header needed!) if it will guarantee a
suitable alignment (which, in practice, will be true the vast majority
of the time).

So in short, this makes `std.heap.c_allocator` more memory efficient,
and probably removes any incentive to use `std.heap.raw_c_allocator`.

I also refactored the `c_allocator` implementation while doing this,
just to neaten things up a little.
2025-12-05 10:19:26 +00:00
..
Build Build.Step.Options: add comptime_float support 2025-11-26 09:57:49 +01:00
builtin std.builtin.assembly: add Clobbers for kvx 2025-11-10 09:40:42 +01:00
c
compress flate.Compress: simplify huffman node comparisons 2025-11-22 22:11:33 -08:00
crypto Argon2: use the std.Io interface 2025-12-02 23:03:52 +01:00
debug update deprecated ArrayListUnmanaged usage (#25958) 2025-11-20 14:46:23 -08:00
dwarf
fmt all: replace all @Type usages 2025-11-22 22:42:38 +00:00
fs Merge pull request #25993 from squeek502/windows-paths 2025-11-24 15:27:24 -08:00
hash all: replace all @Type usages 2025-11-22 22:42:38 +00:00
heap MemoryPool: add unmanaged variants and make them the default 2025-11-15 09:30:57 +00:00
http Revert "std.http: disable failing test on 32-bit arm" 2025-11-01 11:21:28 -04:00
Io std.Io.Threaded: separate out ECANCELED handling again 2025-12-01 19:17:52 -08:00
json std.debug.lockStderrWriter: also return ttyconf 2025-10-30 09:31:28 +00:00
math std.math.big.int: fix format functions 2025-11-23 09:52:43 -08:00
mem
meta all: replace all @Type usages 2025-11-22 22:42:38 +00:00
os std.os.linux: SIG enum is non-exhaustive 2025-12-01 19:17:52 -08:00
posix represent Mac Catalyst as aarch64-maccatalyst-none rather than aarch64-ios-macabi 2025-11-14 11:33:35 +01:00
process std.process.Child: enable rusage collection for dragonfly, netbsd, openbsd 2025-12-04 03:46:36 +01:00
Random
sort
tar
Target std.Target.x86: refresh from update_cpu_features.zig 2025-11-13 22:29:28 +01:00
testing
Thread std.Io.Threaded: slightly different semantics 2025-11-21 19:54:41 -08:00
time
tz
unicode
valgrind
zig std.zig.Ast: count addrspace tokens correctly 2025-12-01 12:56:11 +01:00
zon update deprecated ArrayListUnmanaged usage (#25958) 2025-11-20 14:46:23 -08:00
array_hash_map.zig update deprecated ArrayListUnmanaged usage (#25958) 2025-11-20 14:46:23 -08:00
array_list.zig std.ArrayList: actaully memset to undefined in shrinkRetainingCapacity and clearRetainingCapacity 2025-11-06 05:30:41 -08:00
ascii.zig std: Skip element comparisons if mem.order args point to same memory 2025-10-31 18:34:33 -07:00
atomic.zig
base64.zig Base64DecoderWithIgnore.calcSizeUpperBound cannot return an error (#25834) 2025-11-07 08:16:34 +01:00
bit_set.zig
BitStack.zig
buf_map.zig
buf_set.zig
Build.zig all: replace all @Type usages 2025-11-22 22:42:38 +00:00
builtin.zig compiler: replace @Type with individual type-creating builtins 2025-11-22 22:42:37 +00:00
c.zig std.c: add rusage for dragonfly, netbsd, openbsd 2025-12-04 03:46:36 +01:00
coff.zig
compress.zig
crypto.zig std.crypto: add hybrid post-quantum/traditional key encapsulation 2025-11-27 12:10:17 +01:00
debug.zig fuzzer: account for runtime address slide 2025-11-20 10:42:20 +00:00
deque.zig
DoublyLinkedList.zig
dwarf.zig
dynamic_library.zig represent Mac Catalyst as aarch64-maccatalyst-none rather than aarch64-ios-macabi 2025-11-14 11:33:35 +01:00
elf.zig std.elf implemented DynamicSectionBufferIterator 2025-11-26 11:30:03 +01:00
enums.zig all: replace all @Type usages 2025-11-22 22:42:38 +00:00
fmt.zig all: replace all @Type usages 2025-11-22 22:42:38 +00:00
fs.zig represent Mac Catalyst as aarch64-maccatalyst-none rather than aarch64-ios-macabi 2025-11-14 11:33:35 +01:00
gpu.zig
hash.zig all: replace all @Type usages 2025-11-22 22:42:38 +00:00
hash_map.zig update deprecated ArrayListUnmanaged usage (#25958) 2025-11-20 14:46:23 -08:00
heap.zig std.heap: rework c_allocator 2025-12-05 10:19:26 +00:00
http.zig http.requestHasBody: a PUT response can have a body 2025-11-26 20:08:14 -08:00
Io.zig std.Io.Threaded: fix the cancellation race 2025-12-01 19:17:52 -08:00
json.zig
leb128.zig
log.zig all: replace all @Type usages 2025-11-22 22:42:38 +00:00
macho.zig std.debug: split up Mach-O debug info handling 2025-11-20 10:42:20 +00:00
math.zig all: replace all @Type usages 2025-11-22 22:42:38 +00:00
mem.zig all: replace all @Type usages 2025-11-22 22:42:38 +00:00
meta.zig all: replace all @Type usages 2025-11-22 22:42:38 +00:00
multi_array_list.zig all: replace all @Type usages 2025-11-22 22:42:38 +00:00
once.zig
os.zig os.windows: Delete unused functions and kernel32 bindings 2025-11-23 23:38:01 -08:00
pdb.zig
pie.zig std.pie: add missing clobbers on alpha and sparc 2025-11-14 12:19:38 +01:00
posix.zig std.Io.Threaded: use musl's beautiful pthread_cancel semantics 2025-12-01 19:17:52 -08:00
priority_dequeue.zig
priority_queue.zig
process.zig std.process.ArgIteratorWasi: fix no-args deinit 2025-12-03 08:35:24 +01:00
Progress.zig std.Progress: Terminate progress escape codes with ST not BEL 2025-11-26 14:16:08 +01:00
Random.zig
SemanticVersion.zig
simd.zig std.simd: suggest 1024-bit vectors for kvx 2025-11-10 09:40:44 +01:00
SinglyLinkedList.zig
sort.zig std.sort.partitionPoint: faster implementation (#30005) 2025-11-27 20:48:54 +01:00
start.zig std.start: add kvx support 2025-11-10 09:40:44 +01:00
static_string_map.zig
std.zig all: replace all @Type usages 2025-11-22 22:42:38 +00:00
tar.zig update deprecated ArrayListUnmanaged usage (#25958) 2025-11-20 14:46:23 -08:00
Target.zig std.Target: remove Abi.code16 2025-11-23 10:22:03 +01:00
testing.zig std.testing: Fix expectEqualDeep formatted enum (#25960) 2025-11-25 05:39:07 -08:00
Thread.zig std.Thread: update doc comments 2025-11-21 19:54:41 -08:00
time.zig represent Mac Catalyst as aarch64-maccatalyst-none rather than aarch64-ios-macabi 2025-11-14 11:33:35 +01:00
treap.zig
tz.zig
unicode.zig
Uri.zig
valgrind.zig
wasm.zig
zig.zig compiler: replace @Type with individual type-creating builtins 2025-11-22 22:42:37 +00:00
zip.zig
zon.zig