1cfree(3)                   Library Functions Manual                   cfree(3)
2
3
4

NAME

6       cfree - free allocated memory
7

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

12       #include <stdlib.h>
13
14       /* In SunOS 4 */
15       int cfree(void *ptr);
16
17       /* In glibc or FreeBSD libcompat */
18       void cfree(void *ptr);
19
20       /* In SCO OpenServer */
21       void cfree(char ptr[.size * .num], unsigned int num, unsigned int size);
22
23       /* In Solaris watchmalloc.so.1 */
24       void cfree(void ptr[.elsize * .nelem], size_t nelem, size_t elsize);
25
26   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
27
28       cfree():
29           Since glibc 2.19:
30               _DEFAULT_SOURCE
31           glibc 2.19 and earlier:
32               _BSD_SOURCE || _SVID_SOURCE
33

DESCRIPTION

35       This  function  should  never  be used.  Use free(3) instead.  Starting
36       with glibc 2.26, it has been removed from glibc.
37
38   1-arg cfree
39       In glibc, the function cfree() is a synonym  for  free(3),  "added  for
40       compatibility with SunOS".
41
42       Other  systems have other functions with this name.  The declaration is
43       sometimes in <stdlib.h> and sometimes in <malloc.h>.
44
45   3-arg cfree
46       Some SCO and Solaris versions have malloc libraries with  a  3-argument
47       cfree(), apparently as an analog to calloc(3).
48
49       If you need it while porting something, add
50
51           #define cfree(p, n, s) free((p))
52
53       to your file.
54
55       A  frequently asked question is "Can I use free(3) to free memory allo‐
56       cated with calloc(3), or do I need cfree()?"  Answer: use free(3).
57
58       An SCO manual writes: "The cfree routine is provided for compliance  to
59       the  iBCSe2 standard and simply calls free.  The num and size arguments
60       to cfree are not used."
61

RETURN VALUE

63       The SunOS version of cfree() (which is a synonym for free(3)) returns 1
64       on success and 0 on failure.  In case of error, errno is set to EINVAL:
65       the value of ptr was not a pointer to a block previously  allocated  by
66       one of the routines in the malloc(3) family.
67

ATTRIBUTES

69       For  an  explanation  of  the  terms  used  in  this  section,  see at‐
70       tributes(7).
71
72       ┌─────────────────────────────┬───────────────┬────────────────────────┐
73Interface                    Attribute     Value                  
74       ├─────────────────────────────┼───────────────┼────────────────────────┤
75cfree()                      │ Thread safety │ MT-Safe /* In glibc */ │
76       └─────────────────────────────┴───────────────┴────────────────────────┘
77

VERSIONS

79       The 3-argument version of cfree() as used by SCO conforms to the iBCSe2
80       standard: Intel386 Binary Compatibility Specification, Edition 2.
81

STANDARDS

83       None.
84

HISTORY

86       Removed in glibc 2.26.
87

SEE ALSO

89       malloc(3)
90
91
92
93Linux man-pages 6.04              2023-03-30                          cfree(3)
Impressum