Blame man3/cfree.3

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