Skip to content
Commit f4f2ca15 authored by Siddhesh Poyarekar's avatar Siddhesh Poyarekar
Browse files

realloc: Return unchanged if request is within usable size



If there is enough space in the chunk to satisfy the new size, return
the old pointer as is, thus avoiding any locks or reallocations.  The
only real place this has a benefit is in large chunks that tend to get
satisfied with mmap, since there is a large enough spare size (up to a
page) for it to matter.  For allocations on heap, the extra size is
typically barely a few bytes (up to 15) and it's unlikely that it would
make much difference in performance.

Also added a smoke test to ensure that the old pointer is returned
unchanged if the new size to realloc is within usable size of the old
pointer.

Signed-off-by: default avatarSiddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed-by: default avatarDJ Delorie <dj@redhat.com>
parent 929ea132
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment