From 84e56ad2cf3f4b33089396bba6483888d54d99a3 Mon Sep 17 00:00:00 2001 From: tedu <> Date: Tue, 18 May 2010 22:24:55 +0000 Subject: add posix_madvise, posix_memalign, strndup, and strnlen. mostly from brad and millert, with hints from guenther, jmc, and otto I think. ok previous. --- src/lib/libc/string/strdup.3 | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'src/lib/libc/string/strdup.3') diff --git a/src/lib/libc/string/strdup.3 b/src/lib/libc/string/strdup.3 index 60a7462777..05dcb794f0 100644 --- a/src/lib/libc/string/strdup.3 +++ b/src/lib/libc/string/strdup.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: strdup.3,v 1.15 2010/03/24 14:47:46 kettenis Exp $ +.\" $OpenBSD: strdup.3,v 1.16 2010/05/18 22:24:55 tedu Exp $ .\" .\" Copyright (c) 1990, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,16 +29,19 @@ .\" .\" @(#)strdup.3 8.1 (Berkeley) 6/9/93 .\" -.Dd $Mdocdate: March 24 2010 $ +.Dd $Mdocdate: May 18 2010 $ .Dt STRDUP 3 .Os .Sh NAME -.Nm strdup +.Nm strdup , +.Nm strndup .Nd save a copy of a string .Sh SYNOPSIS .Fd #include .Ft char * .Fn strdup "const char *s" +.Ft char * +.Fn strndup "const char *s" "size_t maxlen" .Sh DESCRIPTION The .Fn strdup @@ -48,6 +51,16 @@ 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 +The +.Fn strndup +function behaves similarly to +.Nm strdup +but only copies up to +.Fa maxlen +characters from +.Fa s . +The resulting string is always NUL-terminated. +.Pp If insufficient memory is available, .Dv NULL is returned. @@ -83,3 +96,15 @@ The .Fn strdup function first appeared in .Bx 4.4 . +.Pp +The +.Fn strndup +function first appeared in +.Ox 4.8 . +.Sh STANDARDS +The +.Fn strdup +and +.Fn strndup +functions conform to +.St -p1003.1-2008 . -- cgit v1.2.3-55-g6feb