cfree(3)

πŸ’– cfree(3) β€” it's giving "free but make it vintage" πŸ’–

okay bestie, welcome to the Library Functions Manual corner of the internet, where today's main character is cfree, the function that literally nobody should be using. like, the whole vibe of this page is "please don't." but we're gonna learn about it anyway because history is important and so are you 🫢


✨ NAME ✨

cfree β€” free allocated memory

πŸ“š LIBRARY πŸ“š

Standard C library (libc, -lc)

πŸŽ€ SYNOPSIS πŸŽ€

#include <stdlib.h>

/* In SunOS 4 */
int cfree(void *ptr);

/* In glibc or FreeBSD libcompat */
void cfree(void *ptr);

/* In SCO OpenServer */
void cfree(unsigned int n, unsigned int size;
           char ptr[size * n], unsigned int n, unsigned int size);

/* In Solaris watchmalloc.so.1 */
void cfree(size_t n, size_t size;
           void ptr[size * n], size_t n, size_t size);

🧚 Feature Test Macro Requirements for glibc (see feature_test_macros(7)): 🧚

cfree():
    Since glibc 2.19:
        _DEFAULT_SOURCE
    glibc 2.19 and earlier:
        _BSD_SOURCE || _SVID_SOURCE

πŸ’… DESCRIPTION πŸ’…

🚨 This function should never be used. Use free(3) instead. Starting with glibc 2.26, it has been removed from glibc.

like... that's the whole tea. but okay, let me tell you about it anyway because context is iconic ✨

🌸 1-arg cfree 🌸

In glibc, the function cfree() is a synonym for free(3), "added for compatibility with SunOS".

Other systems have other functions with this name β€” the way that names get reused is honestly chaotic 😭. The declaration is sometimes in <stdlib.h> and sometimes in <malloc.h>.

🌈 3-arg cfree 🌈

Some SCO and Solaris versions have malloc libraries with a 3-argument cfree(), apparently as an analog to calloc(3).

If you need it while porting something, add this to your file:

#define cfree(p, n, s) free((p))

A frequently asked question is "Can I use free(3) to free memory allocated with calloc(3), or do I need cfree()?" Answer: use free(3).

An SCO manual writes: "The cfree routine is provided for compliance to the iBCSe2 standard and simply calls free. The n and size arguments to cfree are not used."


⭐ RETURN VALUE ⭐

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


πŸ‘‘ ATTRIBUTES πŸ‘‘

For an explanation of the terms used in this section, see attributes(7).

(sorry bestie, the original was a table, but we do bullets here β€” same facts, cuter outfit πŸ’–)

  • Interface: cfree()
  • Attribute: Thread safety
  • Value: MT-Safe /* In glibc */

πŸ¦‹ VERSIONS πŸ¦‹

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


πŸ’€ STANDARDS πŸ’€

None.

like... none. zero. empty. the vibe is "not applicable, bestie." πŸ™ˆ


πŸ“ HISTORY πŸ“

Removed in glibc 2.26.


πŸ”₯ SEE ALSO πŸ”₯

malloc(3)


and that's the whole page!! you understood the assignment πŸ’œ this was Linux man-pages 6.20, dated 2026-02-08 β€” now go use free(3) like a good little coder, no cap πŸŽ€βœ¨

πŸ“¦ where this page comes from
  • arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • πŸ“œ the page's license: GPL-2.0-or-later
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms