]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
malloc: Improve csize2tidx
authorWilco Dijkstra <wilco.dijkstra@arm.com>
Tue, 18 Mar 2025 12:14:52 +0000 (12:14 +0000)
committerWilco Dijkstra <wilco.dijkstra@arm.com>
Tue, 18 Mar 2025 19:19:33 +0000 (19:19 +0000)
Remove the alignment rounding up from csize2tidx - this makes no sense
since the input should be a chunk size.  Removing it enables further
optimizations, for example chunksize_nomask can be safely used and
invalid sizes < MINSIZE are not mapped to a valid tidx.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
malloc/malloc.c

index 931ca481127c6f5199787058d86a0621328de04b..55fb2ab0ecd5491591e0d04ae38a9bd1088af623 100644 (file)
 # define tidx2usize(idx)       (((size_t) idx) * MALLOC_ALIGNMENT + MINSIZE - SIZE_SZ)
 
 /* When "x" is from chunksize().  */
-# define csize2tidx(x) (((x) - MINSIZE + MALLOC_ALIGNMENT - 1) / MALLOC_ALIGNMENT)
+# define csize2tidx(x) (((x) - MINSIZE) / MALLOC_ALIGNMENT)
 /* When "x" is a user-provided size.  */
 # define usize2tidx(x) csize2tidx (request2size (x))