cfree

Section: C Library Functions (3)
Updated: 2026-02-08
Index JM Home Page roff page
 

名前

cfree - 割り当てられたメモリーを解放する  

ライブラリ

標準 C ライブラリ (libc,~-lc)  

書式


#include <stdlib.h>

/* SunOS 4 では */
int cfree(void *ptr);

/* glibc と 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);

glibc 向けの機能検査マクロの要件 (feature_test_macros(7) 参照):

cfree():

    Since glibc 2.19:
        _DEFAULT_SOURCE
    glibc 2.19 and earlier:
        _BSD_SOURCE || _SVID_SOURCE
 

説明

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

引数が 1 つの cfree

glibc では、関数 cfree() は free(3) の別名であり、「SunOS との互換性のために追加された」。

他のシステムでは、この名前の別の関数がある。 この宣言は <stdlib.h> に存在する場合もあるし、 <malloc.h> に存在する場合もある。  

引数が 3 つの cfree

SCO と Solaris のいくつかのバージョンでは、 引数が 3 つの cfree() が含まれる malloc ライブラリがある。 これは明らかに calloc(3) に類似している。

何かを移植する時にこの関数が必要な場合、

#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."  

返り値

SunOS 版の cfree() (free(3) の別名) は、成功した場合に 1 を返し、失敗した場合に 0 を返す。 エラーの場合、 errno が EINVAL に設定される: ptr の値が malloc() 系のルーチンの 1 つで以前に割り当てられた ブロックへのポインターでない。  

属性

この節で使用されている用語の説明については、 attributes(7) を参照。
インターフェース属性値
cfree() Thread safetyMT-Safe /* glibc では */
 

バージョン

SCO で用いられている引数が 3 つの cfree() は、iBCSe2 規格: Intel386 Binary Compatibility Specification, Edition 2 (Intel386 バイナリ互換仕様、第 2 版) に準拠する。  

標準規格

なし。  

歴史

Removed in glibc 2.26.  

関連項目

malloc(3)


 

Index

名前
ライブラリ
書式
説明
引数が 1 つの cfree
引数が 3 つの cfree
返り値
属性
バージョン
標準規格
歴史
関連項目

This document was created by man2html, using the manual pages.