aboutsummaryrefslogtreecommitdiff
path: root/malloc/malloc-debug.c
diff options
context:
space:
mode:
authorDJ Delorie <dj@redhat.com>2023-03-21 00:46:43 -0400
committerDJ Delorie <dj@redhat.com>2023-05-08 16:40:10 -0400
commitd1417176a35d27ffb8da0ffb1e33154163b6eeb2 (patch)
treeaa3e8cd61cadf5fec88e4cf57cfaf4b0e0ae6538 /malloc/malloc-debug.c
parentcea74a4a24c36202309e8254f1f938e2166488f3 (diff)
downloadglibc-d1417176a35d27ffb8da0ffb1e33154163b6eeb2.tar
glibc-d1417176a35d27ffb8da0ffb1e33154163b6eeb2.tar.gz
glibc-d1417176a35d27ffb8da0ffb1e33154163b6eeb2.tar.bz2
glibc-d1417176a35d27ffb8da0ffb1e33154163b6eeb2.zip
aligned_alloc: conform to C17
This patch adds the strict checking for power-of-two alignments in aligned_alloc(), and updates the manual accordingly. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Diffstat (limited to 'malloc/malloc-debug.c')
-rw-r--r--malloc/malloc-debug.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/malloc/malloc-debug.c b/malloc/malloc-debug.c
index 3867d15698..da9d2340d3 100644
--- a/malloc/malloc-debug.c
+++ b/malloc/malloc-debug.c
@@ -299,7 +299,14 @@ __debug_memalign (size_t alignment, size_t bytes)
return _debug_mid_memalign (alignment, bytes, RETURN_ADDRESS (0));
}
strong_alias (__debug_memalign, memalign)
-strong_alias (__debug_memalign, aligned_alloc)
+static void *
+__debug_aligned_alloc (size_t alignment, size_t bytes)
+{
+ if (!powerof2 (alignment) || alignment == 0)
+ return NULL;
+ return _debug_mid_memalign (alignment, bytes, RETURN_ADDRESS (0));
+}
+strong_alias (__debug_aligned_alloc, aligned_alloc)
static void *
__debug_pvalloc (size_t bytes)