File: cfree.3

package info (click to toggle)
manpages 3.44-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 12,880 kB
  • sloc: sh: 404; perl: 166; makefile: 87; lisp: 22
file content (125 lines) | stat: -rw-r--r-- 3,238 bytes parent folder | download | duplicates (2)
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
.\" Copyright (c) 2003 Andries Brouwer (aeb@cwi.nl)
.\"
.\" 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, write to the Free
.\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
.\" USA.
.\"
.TH CFREE 3 2007-07-26  "" "Linux Programmer's Manual"
.SH NAME
cfree \- free allocated memory
.SH SYNOPSIS
.nf
.sp
.B "#include <stdlib.h>"
.sp
/* In SunOS 4 */
.BI "int cfree(void *" ptr );
.sp
/* In glibc or FreeBSD libcompat */
.BI "void cfree(void *" ptr );
.sp
/* In SCO OpenServer */
.BI "void cfree(char *" ptr ", unsigned " num ", unsigned " size );
.sp
/* In Solaris watchmalloc.so.1 */
.BI "void cfree(void *" ptr ", size_t " nelem ", size_t " elsize );
.fi
.sp
.in -4n
Feature Test Macro Requirements for glibc (see
.BR feature_test_macros (7)):
.in
.sp
.BR cfree ():
_BSD_SOURCE || _SVID_SOURCE
.SH DESCRIPTION
This function should never be used.
Use
.BR free (3)
instead.
.SS "1-arg cfree"
In glibc, the function
.BR cfree ()
is a synonym for
.BR free (3),
"added for compatibility with SunOS".
.LP
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).
.LP
If you need it while porting something, add
.sp
.in +4n
#define cfree(p, n, s) free((p))
.in
.sp
to your file.
.LP
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).
.LP
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 "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 3.44 of the Linux
.I man-pages
project.
A description of the project,
and information about reporting bugs,
can be found at
http://www.kernel.org/doc/man-pages/.