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