C examples for stdlib.h:free
function
<cstdlib> <stdlib.h>
Deallocate memory block
void free (void* ptr);
Parameter | Description |
---|---|
ptr | Pointer to a memory block allocated with malloc, calloc or realloc. |
none
#include <stdlib.h> int main ()/* w w w . j a v a 2 s. co m*/ { int * buffer1, * buffer2, * buffer3; buffer1 = (int*) malloc (100*sizeof(int)); buffer2 = (int*) calloc (100,sizeof(int)); buffer3 = (int*) realloc (buffer2,500*sizeof(int)); free (buffer1); free (buffer2); free (buffer3); return 0; }