OSDN Git Service

22698b5bf9b5cd801d6a5fa7aaa7415d8b0a10f7
[linuxjm/LDP_man-pages.git] / release / man3 / cfree.3
1 .\" Copyright (c) 2003 Andries Brouwer (aeb@cwi.nl)
2 .\"
3 .\" This is free documentation; you can redistribute it and/or
4 .\" modify it under the terms of the GNU General Public License as
5 .\" published by the Free Software Foundation; either version 2 of
6 .\" the License, or (at your option) any later version.
7 .\"
8 .\" The GNU General Public License's references to "object code"
9 .\" and "executables" are to be interpreted as the output of any
10 .\" document formatting or typesetting system, including
11 .\" intermediate and printed output.
12 .\"
13 .\" This manual is distributed in the hope that it will be useful,
14 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
15 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 .\" GNU General Public License for more details.
17 .\"
18 .\" You should have received a copy of the GNU General Public
19 .\" License along with this manual; if not, write to the Free
20 .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
21 .\" USA.
22 .\"
23 .\" Japanese Version Copyright (c) 2004 Yuichi SATO
24 .\"         all rights reserved.
25 .\" Translated Mon Jul 19 04:38:03 JST 2004
26 .\"         by Yuichi SATO <ysato444@yahoo.co.jp>
27 .\"
28 .TH CFREE 3 2007-07-26  "" "Linux Programmer's Manual"
29 .SH 名前
30 cfree \- 割り当てられたメモリを解放する
31 .SH 書式
32 .nf
33 .sp
34 .B "#include <stdlib.h>"
35 .sp
36 /* SunOS 4 では */
37 .BI "int cfree(void *" ptr );
38 .sp
39 /* glibc と FreeBSD libcompat では */
40 .BI "void cfree(void *" ptr );
41 .sp
42 /* SCO OpenServer では */
43 .BI "void cfree(char *" ptr ", unsigned " num ", unsigned " size );
44 .sp
45 /* Solaris watchmalloc.so.1 では */
46 .BI "void cfree(void *" ptr ", size_t " nelem ", size_t " elsize );
47 .fi
48 .sp
49 .in -4n
50 glibc 向けの機能検査マクロの要件
51 .RB ( feature_test_macros (7)
52 参照):
53 .in
54 .sp
55 .BR cfree ():
56 _BSD_SOURCE || _SVID_SOURCE
57 .SH 説明
58 この関数は決して使用すべきではない。
59 代わりに
60 .BR free (3)
61 を使うこと。
62 .SS "引き数が 1 つの cfree"
63 glibc では、関数
64 .BR cfree ()
65
66 .BR free (3)
67 の別名であり、「SunOS との互換性のために追加された」。
68 .LP
69 他のシステムでは、この名前の別の関数がある。
70 この宣言は
71 .I <stdlib.h>
72 に存在する場合もあるし、
73 .I <malloc.h>
74 に存在する場合もある。
75 .SS "引き数が 3 つの cfree"
76 SCO と Solaris のいくつかのバージョンでは、
77 引き数が 3 つの
78 .BR cfree ()
79 が含まれる malloc ライブラリがある。
80 これは明らかに
81 .BR calloc (3)
82 に類似している。
83 .LP
84 何かを移植する時にこの関数が必要な場合、
85 .sp
86 .in +4n
87 #define cfree(p, n, s) free((p))
88 .in
89 .sp
90 をファイルに追加すること。
91 .LP
92 よく尋ねられる質問は
93 .RB 「 calloc (3)
94 で割り当てられたメモリを解放するのに
95 .BR free (3)
96 を使うことができるか、
97 それとも
98 .BR cfree ()
99 を使う必要があるか」というものである。
100 答え:
101 .BR free (3)
102 を使うこと。
103 .LP
104 SCO のマニュアルには以下のように記述されている:
105 「cfree ルーチンは iBCSe2 規格に従うために提供されており、
106 単に free を呼んでいるだけである。
107 cfree の num と size 引き数は使用されない。」
108 .SH 返り値
109 SunOS 版の
110 .BR cfree ()
111 .RB ( free (3)
112 の別名) は、成功した場合に 1 を返し、失敗した場合に 0 を返す。
113 エラーの場合、
114 .I errno
115
116 .B EINVAL
117 に設定される:
118 .I ptr
119 の値が
120 .BR malloc ()
121 系のルーチンの 1 つで以前に割り当てられた
122 ブロックへのポインタでない。
123 .SH 準拠
124 SCO で用いられている引き数が 3 つの
125 .BR cfree ()
126 は、iBCSe2 規格:
127 Intel386 Binary Compatibility Specification, Edition 2
128 (Intel386 バイナリ互換仕様、第 2 版) に準拠する。
129 .SH 関連項目
130 .BR malloc (3)