tzfile.5, tzselect.8: sync from tzdb upstream
[man-pages.git] / man3 / cfree.3
blob067b800175b7c9439f90a60846f502aafadf190f
1 '\" t
2 .\" Copyright (c) 2003 Andries Brouwer (aeb@cwi.nl)
3 .\"
4 .\" SPDX-License-Identifier: GPL-2.0-or-later
5 .\"
6 .TH cfree 3 (date) "Linux man-pages (unreleased)"
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 .PP
15 .B "#include <stdlib.h>"
16 .PP
17 /* In SunOS 4 */
18 .BI "int cfree(void *" ptr );
19 .PP
20 /* In glibc or FreeBSD libcompat */
21 .BI "void cfree(void *" ptr );
22 .PP
23 /* In SCO OpenServer */
24 .BI "void cfree(char " ptr [. size " * ." num "], unsigned int " num ", \
25 unsigned int " size );
26 .PP
27 /* In Solaris watchmalloc.so.1 */
28 .BI "void cfree(void " ptr [. elsize " * ." nelem "], size_t " nelem ", \
29 size_t " elsize );
30 .fi
31 .PP
32 .RS -4
33 Feature Test Macro Requirements for glibc (see
34 .BR feature_test_macros (7)):
35 .RE
36 .PP
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 .PP
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 .PP
68 If you need it while porting something, add
69 .PP
70 .in +4n
71 .EX
72 #define cfree(p, n, s) free((p))
73 .EE
74 .in
75 .PP
76 to your file.
77 .PP
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 .PP
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 VERSIONS
109 .BR cfree ()
110 function was removed
111 .\" commit 025b33ae84bb8f15b2748a1d8605dca453fce112
112 in glibc 2.26.
113 .SH ATTRIBUTES
114 For an explanation of the terms used in this section, see
115 .BR attributes (7).
116 .ad l
119 allbox;
120 lbx lb lb
121 l l l.
122 Interface       Attribute       Value
124 .BR cfree ()
125 T}      Thread safety   MT-Safe /* In glibc */
129 .sp 1
130 .SH STANDARDS
131 The 3-argument version of
132 .BR cfree ()
133 as used by SCO conforms to the iBCSe2 standard:
134 Intel386 Binary Compatibility Specification, Edition 2.
135 .SH SEE ALSO
136 .BR malloc (3)