diff options
Diffstat (limited to 'src/lib/libc/stdlib/malloc.3')
| -rw-r--r-- | src/lib/libc/stdlib/malloc.3 | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/src/lib/libc/stdlib/malloc.3 b/src/lib/libc/stdlib/malloc.3 index 1f5d9c7104..71c329f9ec 100644 --- a/src/lib/libc/stdlib/malloc.3 +++ b/src/lib/libc/stdlib/malloc.3 | |||
| @@ -30,9 +30,9 @@ | |||
| 30 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 30 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 31 | .\" SUCH DAMAGE. | 31 | .\" SUCH DAMAGE. |
| 32 | .\" | 32 | .\" |
| 33 | .\" $OpenBSD: malloc.3,v 1.115 2017/05/15 18:05:34 tb Exp $ | 33 | .\" $OpenBSD: malloc.3,v 1.116 2018/11/05 08:23:40 otto Exp $ |
| 34 | .\" | 34 | .\" |
| 35 | .Dd $Mdocdate: May 15 2017 $ | 35 | .Dd $Mdocdate: November 5 2018 $ |
| 36 | .Dt MALLOC 3 | 36 | .Dt MALLOC 3 |
| 37 | .Os | 37 | .Os |
| 38 | .Sh NAME | 38 | .Sh NAME |
| @@ -42,7 +42,8 @@ | |||
| 42 | .Nm free , | 42 | .Nm free , |
| 43 | .Nm reallocarray , | 43 | .Nm reallocarray , |
| 44 | .Nm recallocarray , | 44 | .Nm recallocarray , |
| 45 | .Nm freezero | 45 | .Nm freezero , |
| 46 | .Nm aligned_alloc | ||
| 46 | .Nd memory allocation and deallocation | 47 | .Nd memory allocation and deallocation |
| 47 | .Sh SYNOPSIS | 48 | .Sh SYNOPSIS |
| 48 | .In stdlib.h | 49 | .In stdlib.h |
| @@ -60,6 +61,8 @@ | |||
| 60 | .Fn recallocarray "void *ptr" "size_t oldnmemb" "size_t nmemb" "size_t size" | 61 | .Fn recallocarray "void *ptr" "size_t oldnmemb" "size_t nmemb" "size_t size" |
| 61 | .Ft void | 62 | .Ft void |
| 62 | .Fn freezero "void *ptr" "size_t size" | 63 | .Fn freezero "void *ptr" "size_t size" |
| 64 | .Ft void * | ||
| 65 | .Fn aligned_alloc "size_t alignment" "size_t size" | ||
| 63 | .Vt char *malloc_options ; | 66 | .Vt char *malloc_options ; |
| 64 | .Sh DESCRIPTION | 67 | .Sh DESCRIPTION |
| 65 | The standard functions | 68 | The standard functions |
| @@ -206,7 +209,7 @@ is not | |||
| 206 | .Dv NULL , | 209 | .Dv NULL , |
| 207 | the | 210 | the |
| 208 | .Fa size | 211 | .Fa size |
| 209 | argument must be equal or smaller than the size of the earlier allocation | 212 | argument must be equal to or smaller than the size of the earlier allocation |
| 210 | that returned | 213 | that returned |
| 211 | .Fa ptr . | 214 | .Fa ptr . |
| 212 | .Fn freezero | 215 | .Fn freezero |
| @@ -215,6 +218,21 @@ guarantees the memory range starting at | |||
| 215 | with length | 218 | with length |
| 216 | .Fa size | 219 | .Fa size |
| 217 | is discarded while deallocating the whole object originally allocated. | 220 | is discarded while deallocating the whole object originally allocated. |
| 221 | .Pp | ||
| 222 | The | ||
| 223 | .Fn aligned_alloc | ||
| 224 | function allocates | ||
| 225 | .Fa size | ||
| 226 | bytes of memory such that the allocation's base address is a multiple of | ||
| 227 | .Fa alignment . | ||
| 228 | The requested | ||
| 229 | .Fa alignment | ||
| 230 | must be a power of 2. | ||
| 231 | If | ||
| 232 | .Fa size | ||
| 233 | is not a multiple of | ||
| 234 | .Fa alignment , | ||
| 235 | behavior is undefined. | ||
| 218 | .Sh RETURN VALUES | 236 | .Sh RETURN VALUES |
| 219 | Upon successful completion, the allocation functions | 237 | Upon successful completion, the allocation functions |
| 220 | return a pointer to the allocated space; otherwise, | 238 | return a pointer to the allocated space; otherwise, |
| @@ -223,6 +241,17 @@ is returned and | |||
| 223 | .Va errno | 241 | .Va errno |
| 224 | is set to | 242 | is set to |
| 225 | .Er ENOMEM . | 243 | .Er ENOMEM . |
| 244 | The function | ||
| 245 | .Fn aligned_alloc | ||
| 246 | returns | ||
| 247 | .Dv NULL | ||
| 248 | and sets | ||
| 249 | .Va errno | ||
| 250 | to | ||
| 251 | .Er EINVAL | ||
| 252 | if | ||
| 253 | .Fa alignment | ||
| 254 | is not a power of 2. | ||
| 226 | .Pp | 255 | .Pp |
| 227 | If | 256 | If |
| 228 | .Fa nmemb | 257 | .Fa nmemb |
| @@ -514,6 +543,10 @@ and | |||
| 514 | .Fn free | 543 | .Fn free |
| 515 | functions conform to | 544 | functions conform to |
| 516 | .St -ansiC . | 545 | .St -ansiC . |
| 546 | The | ||
| 547 | .Fn aligned_alloc | ||
| 548 | function conforms to | ||
| 549 | .St -isoC-2011 . | ||
| 517 | .Pp | 550 | .Pp |
| 518 | If | 551 | If |
| 519 | .Fa nmemb | 552 | .Fa nmemb |
| @@ -588,6 +621,10 @@ The | |||
| 588 | .Fn freezero | 621 | .Fn freezero |
| 589 | function appeared in | 622 | function appeared in |
| 590 | .Ox 6.2 . | 623 | .Ox 6.2 . |
| 624 | The | ||
| 625 | .Fn aligned_alloc | ||
| 626 | function appeared in | ||
| 627 | .Ox 6.5 . | ||
| 591 | .Sh CAVEATS | 628 | .Sh CAVEATS |
| 592 | When using | 629 | When using |
| 593 | .Fn malloc , | 630 | .Fn malloc , |
