svn commit: r360664 - head/lib/libc/string
Conrad Meyer
cem at FreeBSD.org
Tue May 5 17:57:05 UTC 2020
Author: cem
Date: Tue May 5 17:57:04 2020
New Revision: 360664
URL: https://svnweb.freebsd.org/changeset/base/360664
Log:
strdup.3: Slightly canonicalize OOM return/error status
Attempted to clean up the language around "this is a malloc'd object." May be
passed as a parameter to free(3) is a bit obtuse.
Sponsored by: Dell EMC Isilon
Modified:
head/lib/libc/string/strdup.3
Modified: head/lib/libc/string/strdup.3
==============================================================================
--- head/lib/libc/string/strdup.3 Tue May 5 17:55:45 2020 (r360663)
+++ head/lib/libc/string/strdup.3 Tue May 5 17:57:04 2020 (r360664)
@@ -28,7 +28,7 @@
.\" @(#)strdup.3 8.1 (Berkeley) 6/9/93
.\" $FreeBSD$
.\"
-.Dd June 6, 2018
+.Dd May 5, 2020
.Dt STRDUP 3
.Os
.Sh NAME
@@ -51,15 +51,12 @@ allocates sufficient memory for a copy
of the string
.Fa str ,
does the copy, and returns a pointer to it.
-The pointer may subsequently be used as an
-argument to the function
-.Xr free 3 .
+The memory is allocated with
+.Xr malloc 3
+and should be released with
+.Xr free 3
+when no longer needed.
.Pp
-If insufficient memory is available, NULL is returned and
-.Va errno
-is set to
-.Er ENOMEM .
-.Pp
The
.Fn strndup
function copies at most
@@ -69,6 +66,14 @@ characters from the string
always
.Dv NUL
terminating the copied string.
+.Sh RETURN VALUES
+If insufficient memory is available, NULL is returned and
+.Va errno
+is set to
+.Er ENOMEM .
+Otherwise, the
+.Fn strdup
+family of functions return a pointer to the copied string.
.Sh SEE ALSO
.Xr free 3 ,
.Xr malloc 3 ,
More information about the svn-src-head
mailing list