OSDN Git Service

(split) LDP: Release pages for LDP v3.39.
[linuxjm/LDP_man-pages.git] / release / man3 / alloca.3
1 .\" Copyright (c) 1980, 1991 Regents of the University of California.
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\"    must display the following acknowledgement:
14 .\"     This product includes software developed by the University of
15 .\"     California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\"    may be used to endorse or promote products derived from this software
18 .\"    without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\"     @(#)alloca.3    5.1 (Berkeley) 5/2/91
33 .\"
34 .\" Converted Mon Nov 29 11:05:55 1993 by Rik Faith <faith@cs.unc.edu>
35 .\" Modified Tue Oct 22 23:41:56 1996 by Eric S. Raymond <esr@thyrsus.com>
36 .\" Modified 2002-07-17, aeb
37 .\" 2008-01-24, mtk:
38 .\"     Various rewrites and additions (notes on longjmp() and SIGSEGV).
39 .\"     Weaken warning against use of alloca() (as per Debian bug 461100).
40 .\"
41 .\"*******************************************************************
42 .\"
43 .\" This file was generated with po4a. Translate the source file.
44 .\"
45 .\"*******************************************************************
46 .TH ALLOCA 3 2008\-01\-24 GNU "Linux Programmer's Manual"
47 .SH 名前
48 alloca \- 自動的に解放されるメモリを割り当てる
49 .SH 書式
50 \fB#include <alloca.h>\fP
51 .sp
52 \fBvoid *alloca(size_t \fP\fIsize\fP\fB);\fP
53 .SH 説明
54 \fBalloca\fP()  関数は、 \fIsize\fP バイトの領域を呼出元のスタック・フレームに割り付ける。 この一時的な領域は、 \fBalloca\fP()
55 を呼び出した関数が呼出元に返るときに自動的に解放される。
56 .SH 返り値
57 \fBalloca\fP()  関数は、割り付けた領域の始まりを指すポインタを返す。 割り付けによってスタックオーバーフローが起った場合の
58 プログラムの動作は定義されていない。
59 .SH 準拠
60 この関数は POSIX.1\-2001 にはない。
61
62 32V, PWB, PWB.2, 3BSD, 4BSD に \fBalloca\fP()  関数が登場した証拠がある。 4.3BSD
63 には、マニュアルページがある。 Linux は、GNU 版を使っている。 この関数は POSIX.1\-2001 にはない。
64 .SH 注意
65 \fBalloca\fP()  関数は、機種とコンパイラに依存する。 特定のアプリケーションでは、この関数を使うと \fBmalloc\fP(3)  と
66 \fBfree\fP(3)  を組み合わせて使った場合に比べて効率を改善することができる。 特定の場合では、この関数を使うことで、 \fBlongjmp\fP(3)
67 や \fBsiglongjmp\fP(3)  を使うアプリケーションでのメモリの開放を簡単にすることができる。
68 それ以外の場合では、この関数の使用は推奨されない。
69
70 \fBalloca\fP()  により割り当てられる空間はスタックフレームから割り当てらるので、 関数の戻り先が \fBlongjmp\fP(3)  や
71 \fBsiglongjmp\fP(3)  の呼び出しによりジャンプした場合には、 割り当てられた空間は自動的に解放される。
72
73 \fBalloca\fP()  で割り当てられた空間を \fBfree\fP(3)  しようとすることのないように!
74 .SS "GNU 版についての注意"
75 通常 \fBgcc\fP(1)  は \fBalloca\fP()  の呼び出しをインラインコードに変換する。 \fI\-ansi\fP, \fI\-std=c89\fP,
76 \fI\-std=c99\fP, \fI\-fno\-builtin\fP のいずれかのオプションが指定された場合、この変換は行われない (また
77 \fI<alloca.h>\fP のインクルードも行われない)。 だだし、デフォルトでは glibc 版の
78 \fI<stdlib.h>\fP は \fI<alloca.h>\fP
79 をインクルードしており、これには以下の行が含まれているので注意すること。
80 .nf
81
82     #define alloca(size)   __builtin_alloca (size)
83
84 .fi
85 独自版の __builtin_alloca (size) 関数があると厄介な結果になる。
86 .LP
87 このコードはインライン化されているので、 この関数のアドレスを取得したり、 他のライブラリをリンクして動作を変更することはできない。
88 .LP
89 通常このインラインコードはスタックポインタを移動する 1 つの命令 (instruction) から構成されており、
90 スタックオーバーフローをチェックしない。 よって NULL エラーが返されることはない。
91 .SH バグ
92 スタックフレームが拡張できなかった場合、エラー通知は行われない。 (しかしながら、割り当てに失敗した後で、プログラムが割り当てられなかった
93 空間にアクセスしようとした場合に \fBSIGSEGV\fP シグナルを受信することだろう。)
94
95 多くのシステムにおいて、関数コールの引き数のリスト内では \fBalloca\fP()  が使えない。 これは、 \fBalloca\fP()
96 によって予約されるスタック領域が、 関数引き数に使われるスタック領域の中に現れてしまうためである。
97 .SH 関連項目
98 \fBbrk\fP(2), \fBlongjmp\fP(3), \fBmalloc\fP(3)