Debian Codegraph @

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