'\" t .\" Copyright (c) 2003 Andries Brouwer (aeb@cwi.nl) .\" .\" SPDX-License-Identifier: GPL-2.0-or-later .\" .TH cfree 3 2024-05-02 "Linux man-pages 6.9.1" .SH NAME cfree \- free allocated memory .SH LIBRARY Standard C library .RI ( libc ", " \-lc ) .SH SYNOPSIS .nf .P .B "#include " .P /* In SunOS 4 */ .BI "int cfree(void *" ptr ); .P /* In glibc or FreeBSD libcompat */ .BI "void cfree(void *" ptr ); .P /* In SCO OpenServer */ .BI "void cfree(char " ptr [. size " * ." num "], unsigned int " num ", \ unsigned int " size ); .P /* In Solaris watchmalloc.so.1 */ .BI "void cfree(void " ptr [. elsize " * ." nelem "], size_t " nelem ", \ size_t " elsize ); .fi .P .RS -4 Feature Test Macro Requirements for glibc (see .BR feature_test_macros (7)): .RE .P .BR cfree (): .nf Since glibc 2.19: _DEFAULT_SOURCE glibc 2.19 and earlier: _BSD_SOURCE || _SVID_SOURCE .fi .SH DESCRIPTION This function should never be used. Use .BR free (3) instead. Starting with glibc 2.26, it has been removed from glibc. .SS 1-arg cfree In glibc, the function .BR cfree () is a synonym for .BR free (3), "added for compatibility with SunOS". .P Other systems have other functions with this name. The declaration is sometimes in .I and sometimes in .IR . .SS 3-arg cfree Some SCO and Solaris versions have malloc libraries with a 3-argument .BR cfree (), apparently as an analog to .BR calloc (3). .P If you need it while porting something, add .P .in +4n .EX #define cfree(p, n, s) free((p)) .EE .in .P to your file. .P A frequently asked question is "Can I use .BR free (3) to free memory allocated with .BR calloc (3), or do I need .BR cfree ()?" Answer: use .BR free (3). .P An SCO manual writes: "The cfree routine is provided for compliance to the iBCSe2 standard and simply calls free. The num and size arguments to cfree are not used." .SH RETURN VALUE The SunOS version of .BR cfree () (which is a synonym for .BR free (3)) returns 1 on success and 0 on failure. In case of error, .I errno is set to .BR EINVAL : the value of .I ptr was not a pointer to a block previously allocated by one of the routines in the .BR malloc (3) family. .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). .TS allbox; lbx lb lb l l l. Interface Attribute Value T{ .na .nh .BR cfree () T} Thread safety MT-Safe /* In glibc */ .TE .SH VERSIONS The 3-argument version of .BR cfree () as used by SCO conforms to the iBCSe2 standard: Intel386 Binary Compatibility Specification, Edition 2. .SH STANDARDS None. .SH HISTORY .\" commit 025b33ae84bb8f15b2748a1d8605dca453fce112 Removed in glibc 2.26. .SH SEE ALSO .BR malloc (3)