Espacios de nombres
Variantes
Acciones

free

De cppreference.com
< c‎ | memory

Defined in header <stdlib.h>
void free( void* ptr );
Desasigna el espacio previamente asignado por malloc(), calloc() o realloc(). Si ptr es nulo puntero, la función no hace nada .
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.
El comportamiento no está definido si ptr no coincide con un puntero devuelto anteriormente por malloc(), calloc() o realloc(). Además, el comportamiento es indefinido si el área de memoria se refiere a por ptr ya ha sido desasignado, es decir, free() o realloc() ya se ha llamado con ptr como el argumento y hay llamadas a malloc(), calloc() o realloc() resultó en un puntero igual a ptr después .
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.

Contenido

[editar] Parámetros

ptr -
puntero a la memoria para desasignar
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.

[editar] Valor de retorno

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

[editar] Ejemplo

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


[editar] Ver también