mount_setattr.2: Reword the description of the 'propagation field'
[man-pages.git] / man3 / cfree.3
blob12301bd3c909f4bb3c656f7a5971f16278cd71c0
1 .\" Copyright (c) 2003 Andries Brouwer (aeb@cwi.nl)
2 .\"
3 .\" %%%LICENSE_START(GPLv2+_DOC_FULL)
4 .\" This is free documentation; you can redistribute it and/or
5 .\" modify it under the terms of the GNU General Public License as
6 .\" published by the Free Software Foundation; either version 2 of
7 .\" the License, or (at your option) any later version.
8 .\"
9 .\" The GNU General Public License's references to "object code"
10 .\" and "executables" are to be interpreted as the output of any
11 .\" document formatting or typesetting system, including
12 .\" intermediate and printed output.
13 .\"
14 .\" This manual is distributed in the hope that it will be useful,
15 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
16 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 .\" GNU General Public License for more details.
18 .\"
19 .\" You should have received a copy of the GNU General Public
20 .\" License along with this manual; if not, see
21 .\" <http://www.gnu.org/licenses/>.
22 .\" %%%LICENSE_END
23 .\"
24 .TH CFREE 3 2021-03-22  "" "Linux Programmer's Manual"
25 .SH NAME
26 cfree \- free allocated memory
27 .SH SYNOPSIS
28 .nf
29 .PP
30 .B "#include <stdlib.h>"
31 .PP
32 /* In SunOS 4 */
33 .BI "int cfree(void *" ptr );
34 .PP
35 /* In glibc or FreeBSD libcompat */
36 .BI "void cfree(void *" ptr );
37 .PP
38 /* In SCO OpenServer */
39 .BI "void cfree(char *" ptr ", unsigned int " num ", unsigned int " size );
40 .PP
41 /* In Solaris watchmalloc.so.1 */
42 .BI "void cfree(void *" ptr ", size_t " nelem ", size_t " elsize );
43 .fi
44 .PP
45 .RS -4
46 Feature Test Macro Requirements for glibc (see
47 .BR feature_test_macros (7)):
48 .RE
49 .PP
50 .BR cfree ():
51 .nf
52     Since glibc 2.19:
53         _DEFAULT_SOURCE
54     Glibc 2.19 and earlier:
55         _BSD_SOURCE || _SVID_SOURCE
56 .fi
57 .SH DESCRIPTION
58 This function should never be used.
59 Use
60 .BR free (3)
61 instead.
62 Starting with version 2.26, it has been removed from glibc.
63 .SS 1-arg cfree
64 In glibc, the function
65 .BR cfree ()
66 is a synonym for
67 .BR free (3),
68 "added for compatibility with SunOS".
69 .PP
70 Other systems have other functions with this name.
71 The declaration is sometimes in
72 .I <stdlib.h>
73 and sometimes in
74 .IR <malloc.h> .
75 .SS 3-arg cfree
76 Some SCO and Solaris versions have malloc libraries with a 3-argument
77 .BR cfree (),
78 apparently as an analog to
79 .BR calloc (3).
80 .PP
81 If you need it while porting something, add
82 .PP
83 .in +4n
84 .EX
85 #define cfree(p, n, s) free((p))
86 .EE
87 .in
88 .PP
89 to your file.
90 .PP
91 A frequently asked question is "Can I use
92 .BR free (3)
93 to free memory allocated with
94 .BR calloc (3),
95 or do I need
96 .BR cfree ()?"
97 Answer: use
98 .BR free (3).
99 .PP
100 An SCO manual writes: "The cfree routine is provided for compliance
101 to the iBCSe2 standard and simply calls free.
102 The num and size
103 arguments to cfree are not used."
104 .SH RETURN VALUE
105 The SunOS version of
106 .BR cfree ()
107 (which is a synonym for
108 .BR free (3))
109 returns 1 on success and 0 on failure.
110 In case of error,
111 .I errno
112 is set to
113 .BR EINVAL :
114 the value of
115 .I ptr
116 was not a pointer to a block previously allocated by
117 one of the routines in the
118 .BR malloc (3)
119 family.
120 .SH VERSIONS
122 .BR cfree ()
123 function was removed
124 .\" commit 025b33ae84bb8f15b2748a1d8605dca453fce112
125 from glibc in version 2.26.
126 .SH ATTRIBUTES
127 For an explanation of the terms used in this section, see
128 .BR attributes (7).
129 .ad l
132 allbox;
133 lbx lb lb
134 l l l.
135 Interface       Attribute       Value
137 .BR cfree ()
138 T}      Thread safety   MT-Safe /* In glibc */
142 .sp 1
143 .SH CONFORMING TO
144 The 3-argument version of
145 .BR cfree ()
146 as used by SCO conforms to the iBCSe2 standard:
147 Intel386 Binary Compatibility Specification, Edition 2.
148 .SH SEE ALSO
149 .BR malloc (3)