1CFREE(3) Linux Programmer's Manual CFREE(3)
2
3
4
6 cfree - free allocated memory
7
9 #include <stdlib.h>
10
11 /* In SunOS 4 */
12 int cfree(void *ptr);
13
14 /* In glibc or FreeBSD libcompat */
15 void cfree(void *ptr);
16
17 /* In SCO OpenServer */
18 void cfree(char *ptr, unsigned num, unsigned size);
19
20 /* In Solaris watchmalloc.so.1 */
21 void cfree(void *ptr, size_t nelem, size_t elsize);
22
23 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
24
25 cfree():
26 Since glibc 2.19:
27 _DEFAULT_SOURCE
28 Glibc 2.19 and earlier:
29 _BSD_SOURCE || _SVID_SOURCE
30
32 This function should never be used. Use free(3) instead. Starting
33 with version 2.26, it has been removed from glibc.
34
35 1-arg cfree
36 In glibc, the function cfree() is a synonym for free(3), "added for
37 compatibility with SunOS".
38
39 Other systems have other functions with this name. The declaration is
40 sometimes in <stdlib.h> and sometimes in <malloc.h>.
41
42 3-arg cfree
43 Some SCO and Solaris versions have malloc libraries with a 3-argument
44 cfree(), apparently as an analog to calloc(3).
45
46 If you need it while porting something, add
47
48 #define cfree(p, n, s) free((p))
49
50 to your file.
51
52 A frequently asked question is "Can I use free(3) to free memory allo‐
53 cated with calloc(3), or do I need cfree()?" Answer: use free(3).
54
55 An SCO manual writes: "The cfree routine is provided for compliance to
56 the iBCSe2 standard and simply calls free. The num and size arguments
57 to cfree are not used."
58
60 The SunOS version of cfree() (which is a synonym for free(3)) returns 1
61 on success and 0 on failure. In case of error, errno is set to EINVAL:
62 the value of ptr was not a pointer to a block previously allocated by
63 one of the routines in the malloc(3) family.
64
66 The cfree() function was removed from glibc in version 2.26.
67
69 For an explanation of the terms used in this section, see
70 attributes(7).
71
72 ┌──────────┬───────────────┬────────────────────────┐
73 │Interface │ Attribute │ Value │
74 ├──────────┼───────────────┼────────────────────────┤
75 │cfree() │ Thread safety │ MT-Safe /* In glibc */ │
76 └──────────┴───────────────┴────────────────────────┘
78 The 3-argument version of cfree() as used by SCO conforms to the iBCSe2
79 standard: Intel386 Binary Compatibility Specification, Edition 2.
80
82 malloc(3)
83
85 This page is part of release 5.02 of the Linux man-pages project. A
86 description of the project, information about reporting bugs, and the
87 latest version of this page, can be found at
88 https://www.kernel.org/doc/man-pages/.
89
90
91
92 2017-09-15 CFREE(3)