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