Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libbsdmalloc libbsdmalloc: Make aligned_alloc(A, S) actu...



details:   https://anonhg.NetBSD.org/src/rev/8c4612a4ae91
branches:  trunk
changeset: 377285:8c4612a4ae91
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Wed Jul 05 12:08:49 2023 +0000

description:
libbsdmalloc: Make aligned_alloc(A, S) actually align when A > S.

XXX pullup-10

diffstat:

 lib/libbsdmalloc/malloc.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r 302912a0c799 -r 8c4612a4ae91 lib/libbsdmalloc/malloc.c
--- a/lib/libbsdmalloc/malloc.c Wed Jul 05 12:07:21 2023 +0000
+++ b/lib/libbsdmalloc/malloc.c Wed Jul 05 12:08:49 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: malloc.c,v 1.7 2023/07/05 10:57:44 riastradh Exp $     */
+/*     $NetBSD: malloc.c,v 1.8 2023/07/05 12:08:49 riastradh Exp $     */
 
 /*
  * Copyright (c) 1983, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)malloc.c   8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: malloc.c,v 1.7 2023/07/05 10:57:44 riastradh Exp $");
+__RCSID("$NetBSD: malloc.c,v 1.8 2023/07/05 12:08:49 riastradh Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -534,7 +534,7 @@ aligned_alloc(size_t alignment, size_t s
                errno = EINVAL;
                return NULL;
        }
-       p = malloc(size);
+       p = malloc(size < alignment ? alignment : size);
        if (__predict_false(p == NULL))
                ASSERT((uintptr_t)p % alignment == 0);
        return p;



Home | Main Index | Thread Index | Old Index