Debian Codegraph @

upstream/fedora-44/man3/cfree.3

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