diff options
author | Siddhesh Poyarekar <siddhesh@sourceware.org> | 2022-11-28 12:26:46 -0500 |
---|---|---|
committer | Siddhesh Poyarekar <siddhesh@sourceware.org> | 2022-12-08 11:23:43 -0500 |
commit | f4f2ca1509288f6f780af50659693a89949e7e46 (patch) | |
tree | 90dd3a1bf876ffc694e0c0da99e836f2749bb37d /misc | |
parent | 929ea132b43dbec93e5f4d28f316d37ede91a635 (diff) | |
download | glibc-f4f2ca1509288f6f780af50659693a89949e7e46.zip glibc-f4f2ca1509288f6f780af50659693a89949e7e46.tar.gz glibc-f4f2ca1509288f6f780af50659693a89949e7e46.tar.bz2 |
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: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed-by: DJ Delorie <dj@redhat.com>
Diffstat (limited to 'misc')
0 files changed, 0 insertions, 0 deletions