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(): _BSD_SOURCE || _SVID_SOURCE
26
28 This function should never be used. Use free(3) instead.
29
30 1-arg cfree
31 In glibc, the function cfree() is a synonym for free(3), "added for
32 compatibility with SunOS".
33
34 Other systems have other functions with this name. The declaration is
35 sometimes in <stdlib.h> and sometimes in <malloc.h>.
36
37 3-arg cfree
38 Some SCO and Solaris versions have malloc libraries with a 3-argument
39 cfree(), apparently as an analog to calloc(3).
40
41 If you need it while porting something, add
42
43 #define cfree(p, n, s) free((p))
44
45 to your file.
46
47 A frequently asked question is "Can I use free(3) to free memory allo‐
48 cated with calloc(3), or do I need cfree()?" Answer: use free(3).
49
50 An SCO manual writes: "The cfree routine is provided for compliance to
51 the iBCSe2 standard and simply calls free. The num and size arguments
52 to cfree are not used."
53
55 The SunOS version of cfree() (which is a synonym for free(3)) returns 1
56 on success and 0 on failure. In case of error, errno is set to EINVAL:
57 the value of ptr was not a pointer to a block previously allocated by
58 one of the routines in the malloc(3) family.
59
61 The 3-argument version of cfree() as used by SCO conforms to the iBCSe2
62 standard: Intel386 Binary Compatibility Specification, Edition 2.
63
65 malloc(3)
66
68 This page is part of release 3.25 of the Linux man-pages project. A
69 description of the project, and information about reporting bugs, can
70 be found at http://www.kernel.org/doc/man-pages/.
71
72
73
74 2007-07-26 CFREE(3)