From 2f1984b823644fa9b991a59ac53261f237301cee Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Sun, 5 Jun 2016 12:35:54 +0200 Subject: [PATCH] kstrdup.9: Mention kstrndup(). --- share/man/man9/Makefile | 1 + share/man/man9/kstrdup.9 | 22 +++++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile index 9831132ef5..3652cfd662 100644 --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -583,6 +583,7 @@ MLINKS+=kprintf.9 krateprintf.9 \ kprintf.9 uprintf.9 MLINKS+=ksignal.9 gsignal.9 \ ksignal.9 pgsignal.9 +MLINKS+=kstrdup.9 kstrndup.9 MLINKS+=ktr.9 KTR_COND_LOG.9 \ ktr.9 KTR_INFO.9 \ ktr.9 KTR_INFO_MASTER.9 \ diff --git a/share/man/man9/kstrdup.9 b/share/man/man9/kstrdup.9 index 4f92cbfe8a..8fe09e9ac2 100644 --- a/share/man/man9/kstrdup.9 +++ b/share/man/man9/kstrdup.9 @@ -28,21 +28,23 @@ .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd January 14, 2016 +.Dd June 5, 2016 .Dt KSTRDUP 9 .Os .Sh NAME -.Nm kstrdup +.Nm kstrdup , +.Nm kstrndup .Nd save a copy of a string .Sh SYNOPSIS .In sys/malloc.h .Ft char * .Fn kstrdup "const char *str" "struct malloc_type *type" +.Ft char * +.Fn kstrndup "const char *str" "size_t maxlen" "struct malloc_type *type" .Sh DESCRIPTION The -.Fn strdup -function -allocates sufficient memory of type +.Fn kstrdup +function allocates sufficient memory of type .Fa type for a copy of the string .Fa str , @@ -50,6 +52,16 @@ does the copy, and returns a pointer to it. The pointer may subsequently be used as an argument to the function .Xr kfree 9 . +.Pp +The +.Fn kstrndup +function copies at most +.Fa maxlen +characters from the string +.Fa str +and will always +.Dv NUL +terminate the copied string. .Sh SEE ALSO .Xr kfree 9 , .Xr kmalloc 9 -- 2.41.0