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
This commit is contained in:
parent
6b1e5fae2c
commit
b34f8412c5
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=360664
@ -28,7 +28,7 @@
|
|||||||
.\" @(#)strdup.3 8.1 (Berkeley) 6/9/93
|
.\" @(#)strdup.3 8.1 (Berkeley) 6/9/93
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd June 6, 2018
|
.Dd May 5, 2020
|
||||||
.Dt STRDUP 3
|
.Dt STRDUP 3
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -51,14 +51,11 @@ allocates sufficient memory for a copy
|
|||||||
of the string
|
of the string
|
||||||
.Fa str ,
|
.Fa str ,
|
||||||
does the copy, and returns a pointer to it.
|
does the copy, and returns a pointer to it.
|
||||||
The pointer may subsequently be used as an
|
The memory is allocated with
|
||||||
argument to the function
|
.Xr malloc 3
|
||||||
.Xr free 3 .
|
and should be released with
|
||||||
.Pp
|
.Xr free 3
|
||||||
If insufficient memory is available, NULL is returned and
|
when no longer needed.
|
||||||
.Va errno
|
|
||||||
is set to
|
|
||||||
.Er ENOMEM .
|
|
||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
.Fn strndup
|
.Fn strndup
|
||||||
@ -69,6 +66,14 @@ characters from the string
|
|||||||
always
|
always
|
||||||
.Dv NUL
|
.Dv NUL
|
||||||
terminating the copied string.
|
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
|
.Sh SEE ALSO
|
||||||
.Xr free 3 ,
|
.Xr free 3 ,
|
||||||
.Xr malloc 3 ,
|
.Xr malloc 3 ,
|
||||||
|
Loading…
Reference in New Issue
Block a user