]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/cfree.3
locale.1, localedef.1, _exit.2, accept.2, access.2, acct.2, adjtimex.2, bdflush.2...
[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.\"
97986708 24.TH CFREE 3 2016-03-15 "" "Linux Programmer's Manual"
fea681da
MK
25.SH NAME
26cfree \- free allocated memory
27.SH SYNOPSIS
28.nf
29.sp
30.B "#include <stdlib.h>"
31.sp
32/* In SunOS 4 */
33.BI "int cfree(void *" ptr );
34.sp
35/* In glibc or FreeBSD libcompat */
36.BI "void cfree(void *" ptr );
37.sp
38/* In SCO OpenServer */
39.BI "void cfree(char *" ptr ", unsigned " num ", unsigned " size );
40.sp
41/* In Solaris watchmalloc.so.1 */
42.BI "void cfree(void *" ptr ", size_t " nelem ", size_t " elsize );
43.fi
cc4615cc
MK
44.sp
45.in -4n
46Feature Test Macro Requirements for glibc (see
47.BR feature_test_macros (7)):
48.in
49.sp
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.
73d8cece 60.SS 1-arg cfree
fea681da 61In glibc, the function
63aa9df0 62.BR cfree ()
fea681da
MK
63is a synonym for
64.BR free (3),
65"added for compatibility with SunOS".
66.LP
67Other systems have other functions with this name.
68The declaration is sometimes in
69.I <stdlib.h>
70and sometimes in
71.IR <malloc.h> .
73d8cece 72.SS 3-arg cfree
fea681da 73Some SCO and Solaris versions have malloc libraries with a 3-argument
63aa9df0 74.BR cfree (),
fea681da
MK
75apparently as an analog to
76.BR calloc (3).
77.LP
78If you need it while porting something, add
79.sp
088a639b 80.in +4n
fea681da
MK
81#define cfree(p, n, s) free((p))
82.in
83.sp
84to your file.
85.LP
86A frequently asked question is "Can I use
fb186734 87.BR free (3)
fea681da 88to free memory allocated with
fb186734 89.BR calloc (3),
fea681da 90or do I need
40725279 91.BR cfree ()?"
fea681da 92Answer: use
fb186734 93.BR free (3).
fea681da
MK
94.LP
95An SCO manual writes: "The cfree routine is provided for compliance
c13182ef
MK
96to the iBCSe2 standard and simply calls free.
97The num and size
fea681da 98arguments to cfree are not used."
47297adb 99.SH RETURN VALUE
fea681da 100The SunOS version of
63aa9df0 101.BR cfree ()
fea681da 102(which is a synonym for
fb186734 103.BR free (3))
fea681da
MK
104returns 1 on success and 0 on failure.
105In case of error,
106.I errno
a9b4ebbc
MK
107is set to
108.BR EINVAL :
109the value of
fea681da
MK
110.I ptr
111was not a pointer to a block previously allocated by
c13182ef 112one of the routines in the
b5cc2ffb
MK
113.BR malloc (3)
114family.
02db25c3
MS
115.SH ATTRIBUTES
116For an explanation of the terms used in this section, see
117.BR attributes (7).
118.TS
119allbox;
120lb lb lb
121l l l.
122Interface Attribute Value
123T{
124.BR cfree ()
125T} Thread safety MT-Safe /* In glibc */
126.TE
47297adb 127.SH CONFORMING TO
fea681da 128The 3-argument version of
63aa9df0 129.BR cfree ()
fea681da
MK
130as used by SCO conforms to the iBCSe2 standard:
131Intel386 Binary Compatibility Specification, Edition 2.
12960935
MK
132.SH SEE ALSO
133.BR malloc (3)