Пространства имён
Варианты
Действия

free

Материал из cppreference.com
< c | memory

Заголовочный файл <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;
}


[править] См. также