summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/stdlib')
-rw-r--r--lib/libc/stdlib/malloc.c13
-rw-r--r--lib/libc/stdlib/posix_memalign.313
2 files changed, 18 insertions, 8 deletions
diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c
index dc395c4736c..999da6c1e9c 100644
--- a/lib/libc/stdlib/malloc.c
+++ b/lib/libc/stdlib/malloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: malloc.c,v 1.224 2017/04/22 09:12:49 otto Exp $ */
+/* $OpenBSD: malloc.c,v 1.225 2017/05/13 07:11:29 otto Exp $ */
/*
* Copyright (c) 2008, 2010, 2011, 2016 Otto Moerbeek <otto@drijf.net>
* Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org>
@@ -1974,15 +1974,20 @@ mapalign(struct dir_info *d, size_t alignment, size_t sz, int zero_fill)
}
static void *
-omemalign(struct dir_info *pool, size_t alignment, size_t sz, int zero_fill, void *f)
+omemalign(struct dir_info *pool, size_t alignment, size_t sz, int zero_fill,
+ void *f)
{
size_t psz;
void *p;
+ /* If between half a page and a page, avoid MALLOC_MOVE. */
+ if (sz > MALLOC_MAXCHUNK && sz < MALLOC_PAGESIZE)
+ sz = MALLOC_PAGESIZE;
if (alignment <= MALLOC_PAGESIZE) {
/*
- * max(size, alignment) is enough to assure the requested alignment,
- * since the allocator always allocates power-of-two blocks.
+ * max(size, alignment) is enough to assure the requested
+ * alignment, since the allocator always allocates
+ * power-of-two blocks.
*/
if (sz < alignment)
sz = alignment;
diff --git a/lib/libc/stdlib/posix_memalign.3 b/lib/libc/stdlib/posix_memalign.3
index 05ec1b9d148..fcd0a4cbdb4 100644
--- a/lib/libc/stdlib/posix_memalign.3
+++ b/lib/libc/stdlib/posix_memalign.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: posix_memalign.3,v 1.3 2012/06/18 17:03:52 matthew Exp $
+.\" $OpenBSD: posix_memalign.3,v 1.4 2017/05/13 07:11:29 otto Exp $
.\" Copyright (C) 2006 Jason Evans <jasone@FreeBSD.org>.
.\" All rights reserved.
.\"
@@ -28,7 +28,7 @@
.\"
.\" $FreeBSD: src/lib/libc/stdlib/posix_memalign.3,v 1.3 2007/03/28 04:32:51 jasone Exp $
.\"
-.Dd $Mdocdate: June 18 2012 $
+.Dd $Mdocdate: May 13 2017 $
.Dt POSIX_MEMALIGN 3
.Os
.Sh NAME
@@ -56,9 +56,14 @@ must be a power of 2 at least as large as
Memory that is allocated via
.Fn posix_memalign
can be used as an argument in subsequent calls to
-.Xr realloc 3
+.Xr realloc 3 ,
+.Xr reallocarray 3
+and
+.Xr free 3 ,
+but not
+.Xr recallocarray 3
and
-.Xr free 3 .
+.Xr freezero 3 .
.Sh RETURN VALUES
The
.Fn posix_memalign