diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-17 10:52:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-17 10:52:03 +0000 |
commit | 932e4432596447eb9331cc2a2bb74a26a35b4efc (patch) | |
tree | 95161711ea07fd64f0c82d6e7943024c033dd5a8 /upstream/archlinux/man7/string_copying.7 | |
parent | Adding debian version 4.22.0-1. (diff) | |
download | manpages-l10n-932e4432596447eb9331cc2a2bb74a26a35b4efc.tar.xz manpages-l10n-932e4432596447eb9331cc2a2bb74a26a35b4efc.zip |
Merging upstream version 4.23.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'upstream/archlinux/man7/string_copying.7')
-rw-r--r-- | upstream/archlinux/man7/string_copying.7 | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/upstream/archlinux/man7/string_copying.7 b/upstream/archlinux/man7/string_copying.7 index b79739f1..030f12b4 100644 --- a/upstream/archlinux/man7/string_copying.7 +++ b/upstream/archlinux/man7/string_copying.7 @@ -2,7 +2,7 @@ .\" .\" SPDX-License-Identifier: BSD-3-Clause .\" -.TH string_copying 7 2023-12-17 "Linux man-pages 6.06" +.TH string_copying 7 2024-05-14 "Linux man-pages 6.8" .\" ----- NAME :: -----------------------------------------------------/ .SH NAME stpcpy, @@ -61,6 +61,9 @@ const char *restrict " src , // Catenate a null-padded character sequence into a string. .BI "char *strncat(char *restrict " dst ", const char " src "[restrict ." ssize ], .BI " size_t " ssize ); +.P +// Duplicate a null-padded character sequence into a string. +.BI "char *strndup(const char " src [. ssize "], size_t " ssize ); .fi .\" ----- SYNOPSIS :: Known-length character sequences --------------------/ .SS Known-length character sequences @@ -154,6 +157,11 @@ a pointer to the new location of the terminating null character (or one after the last character in a character sequence) after the call, so that the programmer can use it to chain such calls. +.\" ----- DESCRIPTION :: Terms (and abbreviations) :: duplicate -------/ +.TP +.I duplicate +Allocate a new buffer +where a copy is placed. .\" ----- DESCRIPTION :: Copy, catenate, and chain-copy ---------------/ .SS Copy, catenate, and chain-copy Originally, @@ -252,6 +260,8 @@ use and then you can treat it as a known-length character sequence; or use .BR strncat (3) +or +.BR strndup (3) directly. .\" ----- DESCRIPTION :: Known-length character sequences -----------------/ .SS Known-length character sequences @@ -342,7 +352,11 @@ holds a string before the call. has an even more misleading name than the functions above. List of functions: .IP \[bu] 3 +.PD 0 .BR strncat (3) +.IP \[bu] +.BR strndup (3) +.PD .P Other functions operate on an input character sequence to create an output character sequence. @@ -453,6 +467,15 @@ they are not related at all. .IP .I \%stpcpy(mempcpy(dst,\ src,\ strnlen(src,\ NITEMS(src))),\ \[dq]\[dq]) is a faster alternative to this function. +.\" ----- DESCRIPTION :: Functions :: strndup(3) ----------------------/ +.TP +.BR strndup (3) +Duplicate the input character sequence, +contained in a null-padded fixed-size buffer, +into a newly allocated destination string. +.IP +The string must be freed with +.BR free (3). .\" ----- DESCRIPTION :: Functions :: mempcpy(3) ----------------------/ .TP .BR mempcpy (3) @@ -508,6 +531,9 @@ The .I dst pointer, which is useless. +.TP +.BR strndup (3) +The newly allocated string. .\" ----- ERRORS ------------------------------------------------------/ .SH ERRORS Most of these functions don't set @@ -526,6 +552,13 @@ was .B E2BIG The string has been truncated. .RE +.TP +.BR strndup (3) +.RS +.TP +.B ENOMEM +Insufficient memory available to allocate duplicate string. +.RE .\" ----- NOTES :: strscpy(9) -----------------------------------------/ .SH NOTES The Linux kernel has an internal function for copying strings, @@ -689,6 +722,15 @@ strncat(buf, u->ut_user, NITEMS(u->ut_user)); len = strlen(buf); puts(buf); .EE +.\" ----- EXAMPLES :: strndup(3) --------------------------------------/ +.TP +.BR strndup (3) +.EX +buf = strndup(u->ut_user, NITEMS(u->ut_user)); +len = strlen(buf); +puts(buf); +free(buf); +.EE .\" ----- EXAMPLES :: mempcpy(3) --------------------------------------/ .TP .BR mempcpy (3) |