summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib
diff options
context:
space:
mode:
authormillert <>2014-10-30 20:43:35 +0000
committermillert <>2014-10-30 20:43:35 +0000
commit07302bad4c25997a736478e173f7eaf0e4c09ac9 (patch)
treef1c0379623e531ddfc224b0072478ae443875b4c /src/lib/libc/stdlib
parent8d5fe1bc2f13cf7f6d50bfaf47fbd25a6fd15cbb (diff)
downloadopenbsd-07302bad4c25997a736478e173f7eaf0e4c09ac9.tar.gz
openbsd-07302bad4c25997a736478e173f7eaf0e4c09ac9.tar.bz2
openbsd-07302bad4c25997a736478e173f7eaf0e4c09ac9.zip
Don't mention old systems where realloc(NULL, n) didn't work as we
don't want to give people the idea that this is non-portable (it has been present since C89). OK deraadt@ schwarze@
Diffstat (limited to 'src/lib/libc/stdlib')
-rw-r--r--src/lib/libc/stdlib/malloc.318
1 files changed, 7 insertions, 11 deletions
diff --git a/src/lib/libc/stdlib/malloc.3 b/src/lib/libc/stdlib/malloc.3
index 2647434eaa..8ae3ba20e6 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.83 2014/10/23 05:48:40 doug Exp $ 33.\" $OpenBSD: malloc.3,v 1.84 2014/10/30 20:43:35 millert Exp $
34.\" 34.\"
35.Dd $Mdocdate: October 23 2014 $ 35.Dd $Mdocdate: October 30 2014 $
36.Dt MALLOC 3 36.Dt MALLOC 3
37.Os 37.Os
38.Sh NAME 38.Sh NAME
@@ -265,12 +265,13 @@ if ((newp = reallocarray(p, num, size)) == NULL) {
265 ... 265 ...
266.Ed 266.Ed
267.Pp 267.Pp
268Code designed for some ancient platforms avoided calling 268Calling
269.Fn realloc 269.Fn realloc
270with a 270with a
271.Dv NULL 271.Dv NULL
272.Fa ptr . 272.Fa ptr
273Such hacks are no longer necessary in modern code. 273is equivalent to calling
274.Fn malloc .
274Instead of this idiom: 275Instead of this idiom:
275.Bd -literal -offset indent 276.Bd -literal -offset indent
276if (p == NULL) 277if (p == NULL)
@@ -279,12 +280,7 @@ else
279 newp = realloc(p, newsize); 280 newp = realloc(p, newsize);
280.Ed 281.Ed
281.Pp 282.Pp
282Use the following as calling 283Use the following:
283.Fn realloc
284with
285.Dv NULL
286is equivalent to calling
287.Fn malloc :
288.Bd -literal -offset indent 284.Bd -literal -offset indent
289newp = realloc(p, newsize); 285newp = realloc(p, newsize);
290.Ed 286.Ed