1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
'\" t
.\" Copyright (c) 2003 Andries Brouwer (aeb@cwi.nl)
.\"
.\" SPDX-License-Identifier: GPL-2.0-or-later
.\"
.TH cfree 3 2023-10-31 "Linux man-pages 6.7"
.SH NAME
cfree \- free allocated memory
.SH LIBRARY
Standard C library
.RI ( libc ", " \-lc )
.SH SYNOPSIS
.nf
.P
.B "#include <stdlib.h>"
.P
/* In SunOS 4 */
.BI "int cfree(void *" ptr );
.P
/* In glibc or FreeBSD libcompat */
.BI "void cfree(void *" ptr );
.P
/* In SCO OpenServer */
.BI "void cfree(char " ptr [. size " * ." num "], unsigned int " num ", \
unsigned int " size );
.P
/* In Solaris watchmalloc.so.1 */
.BI "void cfree(void " ptr [. elsize " * ." nelem "], size_t " nelem ", \
size_t " elsize );
.fi
.P
.RS -4
Feature Test Macro Requirements for glibc (see
.BR feature_test_macros (7)):
.RE
.P
.BR cfree ():
.nf
Since glibc 2.19:
_DEFAULT_SOURCE
glibc 2.19 and earlier:
_BSD_SOURCE || _SVID_SOURCE
.fi
.SH DESCRIPTION
This function should never be used.
Use
.BR free (3)
instead.
Starting with glibc 2.26, it has been removed from glibc.
.SS 1-arg cfree
In glibc, the function
.BR cfree ()
is a synonym for
.BR free (3),
"added for compatibility with SunOS".
.P
Other systems have other functions with this name.
The declaration is sometimes in
.I <stdlib.h>
and sometimes in
.IR <malloc.h> .
.SS 3-arg cfree
Some SCO and Solaris versions have malloc libraries with a 3-argument
.BR cfree (),
apparently as an analog to
.BR calloc (3).
.P
If you need it while porting something, add
.P
.in +4n
.EX
#define cfree(p, n, s) free((p))
.EE
.in
.P
to your file.
.P
A frequently asked question is "Can I use
.BR free (3)
to free memory allocated with
.BR calloc (3),
or do I need
.BR cfree ()?"
Answer: use
.BR free (3).
.P
An SCO manual writes: "The cfree routine is provided for compliance
to the iBCSe2 standard and simply calls free.
The num and size
arguments to cfree are not used."
.SH RETURN VALUE
The SunOS version of
.BR cfree ()
(which is a synonym for
.BR free (3))
returns 1 on success and 0 on failure.
In case of error,
.I errno
is set to
.BR EINVAL :
the value of
.I ptr
was not a pointer to a block previously allocated by
one of the routines in the
.BR malloc (3)
family.
.SH ATTRIBUTES
For an explanation of the terms used in this section, see
.BR attributes (7).
.TS
allbox;
lbx lb lb
l l l.
Interface Attribute Value
T{
.na
.nh
.BR cfree ()
T} Thread safety MT-Safe /* In glibc */
.TE
.SH VERSIONS
The 3-argument version of
.BR cfree ()
as used by SCO conforms to the iBCSe2 standard:
Intel386 Binary Compatibility Specification, Edition 2.
.SH STANDARDS
None.
.SH HISTORY
.\" commit 025b33ae84bb8f15b2748a1d8605dca453fce112
Removed in glibc 2.26.
.SH SEE ALSO
.BR malloc (3)
|