diff options
-rw-r--r-- | src/lib/libc/stdlib/malloc.c | 13 | ||||
-rw-r--r-- | src/lib/libc/stdlib/posix_memalign.3 | 13 |
2 files changed, 18 insertions, 8 deletions
diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c index dc395c4736..999da6c1e9 100644 --- a/src/lib/libc/stdlib/malloc.c +++ b/src/lib/libc/stdlib/malloc.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: malloc.c,v 1.224 2017/04/22 09:12:49 otto Exp $ */ | 1 | /* $OpenBSD: malloc.c,v 1.225 2017/05/13 07:11:29 otto Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2008, 2010, 2011, 2016 Otto Moerbeek <otto@drijf.net> | 3 | * Copyright (c) 2008, 2010, 2011, 2016 Otto Moerbeek <otto@drijf.net> |
4 | * Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org> | 4 | * 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) | |||
1974 | } | 1974 | } |
1975 | 1975 | ||
1976 | static void * | 1976 | static void * |
1977 | omemalign(struct dir_info *pool, size_t alignment, size_t sz, int zero_fill, void *f) | 1977 | omemalign(struct dir_info *pool, size_t alignment, size_t sz, int zero_fill, |
1978 | void *f) | ||
1978 | { | 1979 | { |
1979 | size_t psz; | 1980 | size_t psz; |
1980 | void *p; | 1981 | void *p; |
1981 | 1982 | ||
1983 | /* If between half a page and a page, avoid MALLOC_MOVE. */ | ||
1984 | if (sz > MALLOC_MAXCHUNK && sz < MALLOC_PAGESIZE) | ||
1985 | sz = MALLOC_PAGESIZE; | ||
1982 | if (alignment <= MALLOC_PAGESIZE) { | 1986 | if (alignment <= MALLOC_PAGESIZE) { |
1983 | /* | 1987 | /* |
1984 | * max(size, alignment) is enough to assure the requested alignment, | 1988 | * max(size, alignment) is enough to assure the requested |
1985 | * since the allocator always allocates power-of-two blocks. | 1989 | * alignment, since the allocator always allocates |
1990 | * power-of-two blocks. | ||
1986 | */ | 1991 | */ |
1987 | if (sz < alignment) | 1992 | if (sz < alignment) |
1988 | sz = alignment; | 1993 | sz = alignment; |
diff --git a/src/lib/libc/stdlib/posix_memalign.3 b/src/lib/libc/stdlib/posix_memalign.3 index 05ec1b9d14..fcd0a4cbdb 100644 --- a/src/lib/libc/stdlib/posix_memalign.3 +++ b/src/lib/libc/stdlib/posix_memalign.3 | |||
@@ -1,4 +1,4 @@ | |||
1 | .\" $OpenBSD: posix_memalign.3,v 1.3 2012/06/18 17:03:52 matthew Exp $ | 1 | .\" $OpenBSD: posix_memalign.3,v 1.4 2017/05/13 07:11:29 otto Exp $ |
2 | .\" Copyright (C) 2006 Jason Evans <jasone@FreeBSD.org>. | 2 | .\" Copyright (C) 2006 Jason Evans <jasone@FreeBSD.org>. |
3 | .\" All rights reserved. | 3 | .\" All rights reserved. |
4 | .\" | 4 | .\" |
@@ -28,7 +28,7 @@ | |||
28 | .\" | 28 | .\" |
29 | .\" $FreeBSD: src/lib/libc/stdlib/posix_memalign.3,v 1.3 2007/03/28 04:32:51 jasone Exp $ | 29 | .\" $FreeBSD: src/lib/libc/stdlib/posix_memalign.3,v 1.3 2007/03/28 04:32:51 jasone Exp $ |
30 | .\" | 30 | .\" |
31 | .Dd $Mdocdate: June 18 2012 $ | 31 | .Dd $Mdocdate: May 13 2017 $ |
32 | .Dt POSIX_MEMALIGN 3 | 32 | .Dt POSIX_MEMALIGN 3 |
33 | .Os | 33 | .Os |
34 | .Sh NAME | 34 | .Sh NAME |
@@ -56,9 +56,14 @@ must be a power of 2 at least as large as | |||
56 | Memory that is allocated via | 56 | Memory that is allocated via |
57 | .Fn posix_memalign | 57 | .Fn posix_memalign |
58 | can be used as an argument in subsequent calls to | 58 | can be used as an argument in subsequent calls to |
59 | .Xr realloc 3 | 59 | .Xr realloc 3 , |
60 | .Xr reallocarray 3 | ||
61 | and | ||
62 | .Xr free 3 , | ||
63 | but not | ||
64 | .Xr recallocarray 3 | ||
60 | and | 65 | and |
61 | .Xr free 3 . | 66 | .Xr freezero 3 . |
62 | .Sh RETURN VALUES | 67 | .Sh RETURN VALUES |
63 | The | 68 | The |
64 | .Fn posix_memalign | 69 | .Fn posix_memalign |