summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorotto <>2017-03-07 06:07:50 +0000
committerotto <>2017-03-07 06:07:50 +0000
commit3c4f58bea7403d47518cc64d65cd733d3c607f8b (patch)
tree3d6e5d44117b13cf7f479d92d38c5aa2ad971117 /src/lib
parentdeb5b03f7173c1875345c8fd248a85078c16dc9f (diff)
downloadopenbsd-3c4f58bea7403d47518cc64d65cd733d3c607f8b.tar.gz
openbsd-3c4f58bea7403d47518cc64d65cd733d3c607f8b.tar.bz2
openbsd-3c4f58bea7403d47518cc64d65cd733d3c607f8b.zip
Some tweaks from jmc@ and describe better what recallocarray does;
help and ok from tom@ and deraadt@
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libc/stdlib/malloc.323
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
119function is similar to 120function is similar to
120.Fn reallocarray 121.Fn reallocarray
121except that it takes care of clearing newly allocated and freed memory. 122except that it takes care of clearing newly allocated memory.
123Additionally, the memory that becomes unallocated while shrinking
124or moving existing allocations is erased.
122If 125If
123.Fa ptr 126.Fa ptr
124is a 127is a
@@ -135,9 +138,9 @@ pointer,
135.Fa oldnmemb 138.Fa oldnmemb
136must be a value such that 139must be a value such that
137.Fa oldnmemb 140.Fa oldnmemb
138* 141*
139.Fa size 142.Fa size
140is the size of an earlier allocation that returned 143is the size of the earlier allocation that returned
141.Fa ptr , 144.Fa ptr ,
142otherwise the behaviour is undefined. 145otherwise the behaviour is undefined.
143.Pp 146.Pp
@@ -204,7 +207,7 @@ to
204.Er ENOMEM . 207.Er ENOMEM .
205.Pp 208.Pp
206If 209If
207.Fa ptr 210.Fa ptr
208is not NULL and multiplying 211is not NULL and multiplying
209.Fa oldnmemb 212.Fa oldnmemb
210and 213and
@@ -220,8 +223,10 @@ to
220.Sh IDIOMS 223.Sh IDIOMS
221Consider 224Consider
222.Fn calloc 225.Fn calloc
223or the extension 226or the extensions
224.Fn reallocarray 227.Fn reallocarray
228and
229.Fn recallocarray
225when there is multiplication in the 230when there is multiplication in the
226.Fa size 231.Fa size
227argument of 232argument of
@@ -547,6 +552,10 @@ The
547.Fn reallocarray 552.Fn reallocarray
548function appeared in 553function appeared in
549.Ox 5.6 . 554.Ox 5.6 .
555The
556.Fn recallocarray
557function appeared in
558.Ox 6.1 .
550.Sh CAVEATS 559.Sh CAVEATS
551When using 560When using
552.Fn malloc , 561.Fn malloc ,