diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libc/stdlib/malloc.3 | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/lib/libc/stdlib/malloc.3 b/src/lib/libc/stdlib/malloc.3 index 66de428cb0..e24a811bec 100644 --- a/src/lib/libc/stdlib/malloc.3 +++ b/src/lib/libc/stdlib/malloc.3 | |||
| @@ -30,15 +30,16 @@ | |||
| 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.102 2017/03/06 18:44:21 otto Exp $ | 33 | .\" $OpenBSD: malloc.3,v 1.103 2017/03/07 06:07:50 otto Exp $ |
| 34 | .\" | 34 | .\" |
| 35 | .Dd $Mdocdate: March 6 2017 $ | 35 | .Dd $Mdocdate: March 7 2017 $ |
| 36 | .Dt MALLOC 3 | 36 | .Dt MALLOC 3 |
| 37 | .Os | 37 | .Os |
| 38 | .Sh NAME | 38 | .Sh NAME |
| 39 | .Nm malloc , | 39 | .Nm malloc , |
| 40 | .Nm calloc , | 40 | .Nm calloc , |
| 41 | .Nm reallocarray , | 41 | .Nm reallocarray , |
| 42 | .Nm recallocarray , | ||
| 42 | .Nm realloc , | 43 | .Nm realloc , |
| 43 | .Nm free | 44 | .Nm free |
| 44 | .Nd memory allocation and deallocation | 45 | .Nd memory allocation and deallocation |
| @@ -118,7 +119,9 @@ The | |||
| 118 | .Fn recallocarray | 119 | .Fn recallocarray |
| 119 | function is similar to | 120 | function is similar to |
| 120 | .Fn reallocarray | 121 | .Fn reallocarray |
| 121 | except that it takes care of clearing newly allocated and freed memory. | 122 | except that it takes care of clearing newly allocated memory. |
| 123 | Additionally, the memory that becomes unallocated while shrinking | ||
| 124 | or moving existing allocations is erased. | ||
| 122 | If | 125 | If |
| 123 | .Fa ptr | 126 | .Fa ptr |
| 124 | is a | 127 | is a |
| @@ -135,9 +138,9 @@ pointer, | |||
| 135 | .Fa oldnmemb | 138 | .Fa oldnmemb |
| 136 | must be a value such that | 139 | must be a value such that |
| 137 | .Fa oldnmemb | 140 | .Fa oldnmemb |
| 138 | * | 141 | * |
| 139 | .Fa size | 142 | .Fa size |
| 140 | is the size of an earlier allocation that returned | 143 | is the size of the earlier allocation that returned |
| 141 | .Fa ptr , | 144 | .Fa ptr , |
| 142 | otherwise the behaviour is undefined. | 145 | otherwise the behaviour is undefined. |
| 143 | .Pp | 146 | .Pp |
| @@ -204,7 +207,7 @@ to | |||
| 204 | .Er ENOMEM . | 207 | .Er ENOMEM . |
| 205 | .Pp | 208 | .Pp |
| 206 | If | 209 | If |
| 207 | .Fa ptr | 210 | .Fa ptr |
| 208 | is not NULL and multiplying | 211 | is not NULL and multiplying |
| 209 | .Fa oldnmemb | 212 | .Fa oldnmemb |
| 210 | and | 213 | and |
| @@ -220,8 +223,10 @@ to | |||
| 220 | .Sh IDIOMS | 223 | .Sh IDIOMS |
| 221 | Consider | 224 | Consider |
| 222 | .Fn calloc | 225 | .Fn calloc |
| 223 | or the extension | 226 | or the extensions |
| 224 | .Fn reallocarray | 227 | .Fn reallocarray |
| 228 | and | ||
| 229 | .Fn recallocarray | ||
| 225 | when there is multiplication in the | 230 | when there is multiplication in the |
| 226 | .Fa size | 231 | .Fa size |
| 227 | argument of | 232 | argument of |
| @@ -547,6 +552,10 @@ The | |||
| 547 | .Fn reallocarray | 552 | .Fn reallocarray |
| 548 | function appeared in | 553 | function appeared in |
| 549 | .Ox 5.6 . | 554 | .Ox 5.6 . |
| 555 | The | ||
| 556 | .Fn recallocarray | ||
| 557 | function appeared in | ||
| 558 | .Ox 6.1 . | ||
| 550 | .Sh CAVEATS | 559 | .Sh CAVEATS |
| 551 | When using | 560 | When using |
| 552 | .Fn malloc , | 561 | .Fn malloc , |
