Namespace
Varianti

free

Da cppreference.com.
< c‎ | memory

Elemento definito nell'header <stdlib.h>
void free( void* ptr );
Rilascia lo spazio precedentemente allocato da malloc(), calloc() o realloc(). Se ptr è null-pointer, la funzione non fa nulla.
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.
Il comportamento è indefinito se ptr non corrisponde a un puntatore restituito in precedenza da malloc(), calloc() o realloc(). Inoltre, il comportamento è indefinito se l'area di memoria a cui si riferisce ptr è già stato deallocato, cioè free() o realloc() è già stato chiamato con ptr come argomento e chiamate per malloc(), calloc() o realloc() portato a un puntatore pari a ptr poi.
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.

Indice

[modifica] Parametri

ptr -
puntatore alla memoria da deallocare
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.

[modifica] Valore di ritorno

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

[modifica] Esempio

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


[modifica] Vedi anche