]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/cfree.3
crypt.3: srcfix: rewrap source lines
[thirdparty/man-pages.git] / man3 / cfree.3
CommitLineData
fea681da
MK
1.\" Copyright (c) 2003 Andries Brouwer (aeb@cwi.nl)
2.\"
1dd72f9c 3.\" %%%LICENSE_START(GPLv2+_DOC_FULL)
fea681da
MK
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
c715f741
MK
20.\" License along with this manual; if not, see
21.\" <http://www.gnu.org/licenses/>.
6a8d8745 22.\" %%%LICENSE_END
fea681da 23.\"
4b8c67d9 24.TH CFREE 3 2017-09-15 "" "Linux Programmer's Manual"
fea681da
MK
25.SH NAME
26cfree \- free allocated memory
27.SH SYNOPSIS
28.nf
68e4db0a 29.PP
fea681da 30.B "#include <stdlib.h>"
68e4db0a 31.PP
fea681da
MK
32/* In SunOS 4 */
33.BI "int cfree(void *" ptr );
68e4db0a 34.PP
fea681da
MK
35/* In glibc or FreeBSD libcompat */
36.BI "void cfree(void *" ptr );
68e4db0a 37.PP
fea681da
MK
38/* In SCO OpenServer */
39.BI "void cfree(char *" ptr ", unsigned " num ", unsigned " size );
68e4db0a 40.PP
fea681da
MK
41/* In Solaris watchmalloc.so.1 */
42.BI "void cfree(void *" ptr ", size_t " nelem ", size_t " elsize );
43.fi
68e4db0a 44.PP
cc4615cc
MK
45.in -4n
46Feature Test Macro Requirements for glibc (see
47.BR feature_test_macros (7)):
48.in
68e4db0a 49.PP
cc4615cc 50.BR cfree ():
51c612fb
MK
51 Since glibc 2.19:
52 _DEFAULT_SOURCE
53 Glibc 2.19 and earlier:
54 _BSD_SOURCE || _SVID_SOURCE
fea681da 55.SH DESCRIPTION
c13182ef
MK
56This function should never be used.
57Use
fea681da
MK
58.BR free (3)
59instead.
ceaad4d8 60Starting with version 2.26, it has been removed from glibc.
73d8cece 61.SS 1-arg cfree
fea681da 62In glibc, the function
63aa9df0 63.BR cfree ()
fea681da
MK
64is a synonym for
65.BR free (3),
66"added for compatibility with SunOS".
dd3568a1 67.PP
fea681da
MK
68Other systems have other functions with this name.
69The declaration is sometimes in
70.I <stdlib.h>
71and sometimes in
72.IR <malloc.h> .
73d8cece 73.SS 3-arg cfree
fea681da 74Some SCO and Solaris versions have malloc libraries with a 3-argument
63aa9df0 75.BR cfree (),
fea681da
MK
76apparently as an analog to
77.BR calloc (3).
dd3568a1 78.PP
fea681da 79If you need it while porting something, add
ba39b288 80.PP
088a639b 81.in +4n
ba39b288 82.EX
fea681da 83#define cfree(p, n, s) free((p))
ba39b288 84.EE
fea681da 85.in
ba39b288 86.PP
fea681da 87to your file.
dd3568a1 88.PP
fea681da 89A frequently asked question is "Can I use
fb186734 90.BR free (3)
fea681da 91to free memory allocated with
fb186734 92.BR calloc (3),
fea681da 93or do I need
40725279 94.BR cfree ()?"
fea681da 95Answer: use
fb186734 96.BR free (3).
dd3568a1 97.PP
fea681da 98An SCO manual writes: "The cfree routine is provided for compliance
c13182ef
MK
99to the iBCSe2 standard and simply calls free.
100The num and size
fea681da 101arguments to cfree are not used."
47297adb 102.SH RETURN VALUE
fea681da 103The SunOS version of
63aa9df0 104.BR cfree ()
fea681da 105(which is a synonym for
fb186734 106.BR free (3))
fea681da
MK
107returns 1 on success and 0 on failure.
108In case of error,
109.I errno
a9b4ebbc
MK
110is set to
111.BR EINVAL :
112the value of
fea681da
MK
113.I ptr
114was not a pointer to a block previously allocated by
c13182ef 115one of the routines in the
b5cc2ffb
MK
116.BR malloc (3)
117family.
a2d7a55e
MK
118.SH VERSIONS
119The
120.BR cfree ()
121function was removed
122.\" commit 025b33ae84bb8f15b2748a1d8605dca453fce112
123from glibc in version 2.26.
02db25c3
MS
124.SH ATTRIBUTES
125For an explanation of the terms used in this section, see
126.BR attributes (7).
127.TS
128allbox;
129lb lb lb
130l l l.
131Interface Attribute Value
132T{
133.BR cfree ()
134T} Thread safety MT-Safe /* In glibc */
135.TE
47297adb 136.SH CONFORMING TO
fea681da 137The 3-argument version of
63aa9df0 138.BR cfree ()
fea681da
MK
139as used by SCO conforms to the iBCSe2 standard:
140Intel386 Binary Compatibility Specification, Edition 2.
12960935
MK
141.SH SEE ALSO
142.BR malloc (3)