]> git.ipfire.org Git - thirdparty/glibc.git/commit
malloc: avoid need for tcache == NULL checks
authorDJ Delorie <dj@redhat.com>
Thu, 28 Aug 2025 20:30:30 +0000 (16:30 -0400)
committerDJ Delorie <dj@redhat.com>
Tue, 21 Oct 2025 20:51:03 +0000 (16:51 -0400)
commit2bf2188fae1f3e48d12fdd26f56ff6881fd0b316
treeab502c25856c8a218aa57782168239258c816733
parent324084649b2da2f6840e3a1b84159a4e9a9e9a74
malloc: avoid need for tcache == NULL checks

Avoid needing to check for tcache == NULL by initializing it
to a dummy read-only tcache structure.  This dummy is all zeros,
so logically it is both full (when you want to put) and empty (when
you want to get).  Also, there are two dummies, one used for
"not yet initialized" and one for "tunables say we shouldn't have
a tcache".

The net result is twofold:

1. Checks for tcache == NULL may be removed from the fast path.
    Whether this makes the fast path faster when tcache is
    disabled is TBD, but the normal case is tcache enabled.

2. no memory for tcache is allocated if tunables disable caching.

Co-authored-by: Florian Weimer <fweimer@redhat.com>
Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
malloc/malloc.c