diff options
author | Wilco Dijkstra <wilco.dijkstra@arm.com> | 2025-05-28 14:44:10 +0000 |
---|---|---|
committer | Wilco Dijkstra <wilco.dijkstra@arm.com> | 2025-06-18 13:37:00 +0000 |
commit | ba32fd7d0479bd566db63e43ab1050ad20ca7a29 (patch) | |
tree | 72536cf8db732634671a6ec033592a569f81db76 | |
parent | c0f0db2d59e0908057205b22b21dd9d626d780c1 (diff) | |
download | glibc-ba32fd7d0479bd566db63e43ab1050ad20ca7a29.zip glibc-ba32fd7d0479bd566db63e43ab1050ad20ca7a29.tar.gz glibc-ba32fd7d0479bd566db63e43ab1050ad20ca7a29.tar.bz2 |
malloc: Cleanup _mid_memalign
Remove unused 'address' parameter from _mid_memalign and callers.
Fix off-by-one alignment calculation in __libc_pvalloc.
Reviewed-by: DJ Delorie <dj@redhat.com>
-rw-r--r-- | malloc/malloc.c | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/malloc/malloc.c b/malloc/malloc.c index 3f91ff4..d28cd66 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -1101,7 +1101,7 @@ static void* _int_realloc(mstate, mchunkptr, INTERNAL_SIZE_T, INTERNAL_SIZE_T); static void* _int_memalign(mstate, size_t, size_t); #if IS_IN (libc) -static void* _mid_memalign(size_t, size_t, void *); +static void* _mid_memalign(size_t, size_t); #endif #if USE_TCACHE @@ -3710,8 +3710,7 @@ libc_hidden_def (__libc_realloc) void * __libc_memalign (size_t alignment, size_t bytes) { - void *address = RETURN_ADDRESS (0); - return _mid_memalign (alignment, bytes, address); + return _mid_memalign (alignment, bytes); } libc_hidden_def (__libc_memalign) @@ -3730,12 +3729,11 @@ aligned_alloc (size_t alignment, size_t bytes) return NULL; } - void *address = RETURN_ADDRESS (0); - return _mid_memalign (alignment, bytes, address); + return _mid_memalign (alignment, bytes); } static void * -_mid_memalign (size_t alignment, size_t bytes, void *address) +_mid_memalign (size_t alignment, size_t bytes) { mstate ar_ptr; void *p; @@ -3807,15 +3805,12 @@ _mid_memalign (size_t alignment, size_t bytes, void *address) void * __libc_valloc (size_t bytes) { - void *address = RETURN_ADDRESS (0); - size_t pagesize = GLRO (dl_pagesize); - return _mid_memalign (pagesize, bytes, address); + return _mid_memalign (GLRO (dl_pagesize), bytes); } void * __libc_pvalloc (size_t bytes) { - void *address = RETURN_ADDRESS (0); size_t pagesize = GLRO (dl_pagesize); size_t rounded_bytes; /* ALIGN_UP with overflow check. */ @@ -3826,9 +3821,8 @@ __libc_pvalloc (size_t bytes) __set_errno (ENOMEM); return NULL; } - rounded_bytes = rounded_bytes & -(pagesize - 1); - return _mid_memalign (pagesize, rounded_bytes, address); + return _mid_memalign (pagesize, rounded_bytes & -pagesize); } static void * __attribute_noinline__ @@ -5939,8 +5933,7 @@ __posix_memalign (void **memptr, size_t alignment, size_t size) return EINVAL; - void *address = RETURN_ADDRESS (0); - mem = _mid_memalign (alignment, size, address); + mem = _mid_memalign (alignment, size); if (mem != NULL) { |