From b34f8412c503f620d86e8a2d47cf70af515aad78 Mon Sep 17 00:00:00 2001 From: Conrad Meyer Date: Tue, 5 May 2020 17:57:04 +0000 Subject: [PATCH] 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 --- lib/libc/string/strdup.3 | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/libc/string/strdup.3 b/lib/libc/string/strdup.3 index 80530be36962..db5a11025dc3 100644 --- a/lib/libc/string/strdup.3 +++ b/lib/libc/string/strdup.3 @@ -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,14 +51,11 @@ 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 . -.Pp -If insufficient memory is available, NULL is returned and -.Va errno -is set to -.Er ENOMEM . +The memory is allocated with +.Xr malloc 3 +and should be released with +.Xr free 3 +when no longer needed. .Pp The .Fn strndup @@ -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 ,