OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / LDP_man-pages / original / 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 .TH CFREE 3 2007-07-26  "" "Linux Programmer's Manual"
24 .SH NAME
25 cfree \- free allocated memory
26 .SH SYNOPSIS
27 .nf
28 .sp
29 .B "#include <stdlib.h>"
30 .sp
31 /* In SunOS 4 */
32 .BI "int cfree(void *" ptr );
33 .sp
34 /* In glibc or FreeBSD libcompat */
35 .BI "void cfree(void *" ptr );
36 .sp
37 /* In SCO OpenServer */
38 .BI "void cfree(char *" ptr ", unsigned " num ", unsigned " size );
39 .sp
40 /* In Solaris watchmalloc.so.1 */
41 .BI "void cfree(void *" ptr ", size_t " nelem ", size_t " elsize );
42 .fi
43 .sp
44 .in -4n
45 Feature Test Macro Requirements for glibc (see
46 .BR feature_test_macros (7)):
47 .in
48 .sp
49 .BR cfree ():
50 _BSD_SOURCE || _SVID_SOURCE
51 .SH DESCRIPTION
52 This function should never be used.
53 Use
54 .BR free (3)
55 instead.
56 .SS "1-arg cfree"
57 In glibc, the function
58 .BR cfree ()
59 is a synonym for
60 .BR free (3),
61 "added for compatibility with SunOS".
62 .LP
63 Other systems have other functions with this name.
64 The declaration is sometimes in
65 .I <stdlib.h>
66 and sometimes in
67 .IR <malloc.h> .
68 .SS "3-arg cfree"
69 Some SCO and Solaris versions have malloc libraries with a 3-argument
70 .BR cfree (),
71 apparently as an analog to
72 .BR calloc (3).
73 .LP
74 If you need it while porting something, add
75 .sp
76 .in +4n
77 #define cfree(p, n, s) free((p))
78 .in
79 .sp
80 to your file.
81 .LP
82 A frequently asked question is "Can I use
83 .BR free (3)
84 to free memory allocated with
85 .BR calloc (3),
86 or do I need
87 .BR cfree ()?"
88 Answer: use
89 .BR free (3).
90 .LP
91 An SCO manual writes: "The cfree routine is provided for compliance
92 to the iBCSe2 standard and simply calls free.
93 The num and size
94 arguments to cfree are not used."
95 .SH "RETURN VALUE"
96 The SunOS version of
97 .BR cfree ()
98 (which is a synonym for
99 .BR free (3))
100 returns 1 on success and 0 on failure.
101 In case of error,
102 .I errno
103 is set to
104 .BR EINVAL :
105 the value of
106 .I ptr
107 was not a pointer to a block previously allocated by
108 one of the routines in the
109 .BR malloc (3)
110 family.
111 .SH "CONFORMING TO"
112 The 3-argument version of
113 .BR cfree ()
114 as used by SCO conforms to the iBCSe2 standard:
115 Intel386 Binary Compatibility Specification, Edition 2.
116 .SH SEE ALSO
117 .BR malloc (3)