名前空間
変種
操作

free

提供: cppreference.com
< c‎ | memory

Defined in header <stdlib.h>
void free( void* ptr );
以前malloc()によって割り当てられた領域の割り当てを解除し、calloc()またはrealloc()ptrがヌルポインタである場合、この関数は何もしません.
Original:
Deallocates the space previously allocated by malloc(), calloc() or realloc(). If ptr is null-pointer, the function does nothing.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
動作は未定義ですptrによって以前に返さmalloc()がポインタと一致しない場合、またはcalloc()realloc()ptrによって参照されるメモリ領域は既に解除されている場合にも、動作は未定義である、つまり、free()またはrealloc()すでに引数としてptrとの呼び出しなしで呼び出されたmalloc()calloc()またはrealloc()に等しいポインタが現れptrその後.
Original:
The behavior is undefined if ptr does not match a pointer returned earlier by malloc(), calloc() or realloc(). Also, the behavior is undefined if the memory area referred to by ptr has already been deallocated, that is, free() or realloc() has already been called with ptr as the argument and no calls to malloc(), calloc() or realloc() resulted in a pointer equal to ptr afterwards.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

目次

[編集] パラメータ

ptr -
解放するメモリへのポインタ
Original:
pointer to the memory to deallocate
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 値を返します

(なし)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集]

#include <stdlib.h>
 
int main(int argc, char* argv[]) {
  int* ptr = (int*) malloc( sizeof(int) );
  free(ptr);
  return 0;
}


[編集] も参照してください