.\" Copyright (c) 2003 Andries Brouwer (aeb@cwi.nl)
.\"
.\" %%%LICENSE_START(GPLv2+_DOC_FULL)
.\" This is free documentation; you can redistribute it and/or
.\" modify it under the terms of the GNU General Public License as
.\" published by the Free Software Foundation; either version 2 of
.\" the License, or (at your option) any later version.
.\"
.\" The GNU General Public License's references to "object code"
.\" and "executables" are to be interpreted as the output of any
.\" document formatting or typesetting system, including
.\" intermediate and printed output.
.\"
.\" This manual is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
.\" GNU General Public License for more details.
.\"
.\" You should have received a copy of the GNU General Public
.\" License along with this manual; if not, see
.\" .
.\" %%%LICENSE_END
.\"
.TH CFREE 3 2017-09-15 "" "Linux Programmer's Manual"
.SH NAME
cfree \- free allocated memory
.SH SYNOPSIS
.nf
.PP
.B "#include "
.PP
/* In SunOS 4 */
.BI "int cfree(void *" ptr );
.PP
/* In glibc or FreeBSD libcompat */
.BI "void cfree(void *" ptr );
.PP
/* In SCO OpenServer */
.BI "void cfree(char *" ptr ", unsigned " num ", unsigned " size );
.PP
/* In Solaris watchmalloc.so.1 */
.BI "void cfree(void *" ptr ", size_t " nelem ", size_t " elsize );
.fi
.PP
.RS -4
Feature Test Macro Requirements for glibc (see
.BR feature_test_macros (7)):
.RE
.PP
.BR cfree ():
Since glibc 2.19:
_DEFAULT_SOURCE
Glibc 2.19 and earlier:
_BSD_SOURCE || _SVID_SOURCE
.SH DESCRIPTION
This function should never be used.
Use
.BR free (3)
instead.
Starting with version 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".
.PP
Other systems have other functions with this name.
The declaration is sometimes in
.I
and sometimes in
.IR .
.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).
.PP
If you need it while porting something, add
.PP
.in +4n
.EX
#define cfree(p, n, s) free((p))
.EE
.in
.PP
to your file.
.PP
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).
.PP
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 VERSIONS
The
.BR cfree ()
function was removed
.\" commit 025b33ae84bb8f15b2748a1d8605dca453fce112
from glibc in version 2.26.
.SH ATTRIBUTES
For an explanation of the terms used in this section, see
.BR attributes (7).
.TS
allbox;
lb lb lb
l l l.
Interface Attribute Value
T{
.BR cfree ()
T} Thread safety MT-Safe /* In glibc */
.TE
.SH CONFORMING TO
The 3-argument version of
.BR cfree ()
as used by SCO conforms to the iBCSe2 standard:
Intel386 Binary Compatibility Specification, Edition 2.
.SH SEE ALSO
.BR malloc (3)
.SH COLOPHON
This page is part of release 5.10 of the Linux
.I man-pages
project.
A description of the project,
information about reporting bugs,
and the latest version of this page,
can be found at
\%https://www.kernel.org/doc/man\-pages/.