free
Syntax
#include
<stdlib.h>
void
free(ptr}
void
*ptr;
Defined
in
memory.
c in
rts.
src
Deallocate
Memory
Description
The free function deallocates memory space (pointed
to
by
ptr)
that was
previously allocated
by
a malloc, calloc, or realloc call. This makes the
memory space
available again.
If
you attempt
to
free unallocated space, the
function takes no action and returns. For more information, see Section
5.1
.3, Dynamic Memory Allocation, on page
5-4.
Example This example allocates
10
bytes and then frees them.
6-40
char
*x;
x =
malloc(lO);
free
(x)
;
/*
allocate
10
bytes
/*
free
10
bytes
*/
*/