OSDN Git Service

(split) LDP: Update draft pages
[linuxjm/LDP_man-pages.git] / draft / man3 / strdup.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" References consulted:
26 .\"     Linux libc source code
27 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
28 .\"     386BSD man pages
29 .\" Modified Sun Jul 25 10:41:34 1993 by Rik Faith (faith@cs.unc.edu)
30 .\" Modified Wed Oct 17 01:12:26 2001 by John Levon <moz@compsoc.man.ac.uk>
31 .\"*******************************************************************
32 .\"
33 .\" This file was generated with po4a. Translate the source file.
34 .\"
35 .\"*******************************************************************
36 .TH STRDUP 3 2013\-04\-19 GNU "Linux Programmer's Manual"
37 .SH 名前
38 strdup, strndup, strdupa, strndupa \- 文字列を複製する
39 .SH 書式
40 .nf
41 \fB#include <string.h>\fP
42 .sp
43 \fBchar *strdup(const char *\fP\fIs\fP\fB);\fP
44 .sp
45 \fBchar *strndup(const char *\fP\fIs\fP\fB, size_t \fP\fIn\fP\fB);\fP
46 .br
47 \fBchar *strdupa(const char *\fP\fIs\fP\fB);\fP
48 .br
49 \fBchar *strndupa(const char *\fP\fIs\fP\fB, size_t \fP\fIn\fP\fB);\fP
50 .fi
51 .sp
52 .in -4n
53 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
54 .in
55 .PD 0
56 .ad l
57 .sp
58 \fBstrdup\fP():
59 .RS 4
60 _SVID_SOURCE || _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
61 .br
62 || /* Since glibc 2.12: */ _POSIX_C_SOURCE\ >=\ 200809L
63 .RE
64 .PP
65 \fBstrndup\fP():
66 .RS 4
67 .TP  4
68 glibc 2.10 以降:
69 POSIX_C_SOURCE\ >=\ 200809L || _XOPEN_SOURCE\ >=\ 700
70 .TP 
71 glibc 2.10 より前:
72 _GNU_SOURCE
73 .RE
74 .PP
75 \fBstrdupa\fP(), \fBstrndupa\fP(): _GNU_SOURCE
76 .ad
77 .PD
78 .SH 説明
79 \fBstrdup\fP()  関数は、文字列 \fIs\fPの複製である 新しい文字列へのポインタを返す。 新しい文字列のためのメモリは \fBmalloc\fP(3)
80 で得ている。 そして、 \fBfree\fP(3)  で解放することができる。
81
82 \fBstrndup\fP() 関数は同様であるが、最大で \fIn\fP バイトを複製する。
83 \fIs\fP が \fIn\fP よりも長い場合、\fIn\fP バイトだけが複製され、
84 終端の NULL バイト (\(aq\e0\(aq)) が追加される。
85
86 \fBstrdupa\fP() と \fBstrndupa\fP() も同様だが、バッファの確保に
87 \fBalloca\fP(3) を使用する点が異なる。
88 これらが使用できるのは GNU GCC ツール群を使う場合だけであり、
89 \fBalloca\fP(3) で説明されているのと同じ制限がある。
90 .SH 返り値
91 成功すると、 \fBstrdup\fP() 関数は複製された文字列へのポインタを返す。 十分なメモリが確保できなかった場合には、 NULL を返し、
92 \fIerrno\fP にエラーの原因を示す値を設定する。
93 .SH エラー
94 .TP 
95 \fBENOMEM\fP
96 複製された文字列を割り当てる十分なメモリが確保できなかった。
97 .SH 準拠
98 .\" 4.3BSD-Reno, not (first) 4.3BSD.
99 \fBstrdup\fP()  は SVr4, 4.3BSD, POSIX.1\-2001 準拠である。 \fBstrndup\fP()  は
100 POSIX.1\-2008 準拠である。 \fBstrdupa\fP(), \fBstrndupa\fP()  は GNU 拡張である。
101 .SH 関連項目
102 \fBalloca\fP(3), \fBcalloc\fP(3), \fBfree\fP(3), \fBmalloc\fP(3), \fBrealloc\fP(3),
103 \fBstring\fP(3), \fBwcsdup\fP(3)
104 .SH この文書について
105 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.52 の一部
106 である。プロジェクトの説明とバグ報告に関する情報は
107 http://www.kernel.org/doc/man\-pages/ に書かれている。