Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

free - Free memory space

&pagelevel(4)&pagelevel

Definition

#include <stdlib.h>

void free(void *p);

free releases the memory space pointed to by p. p must be the the result of a previous
malloc, calloc, or realloc call. Otherwise, the result is undefined!

free is part of a C-specific memory management package with its own free memory
management facility. Memory released with free is not returned to the operating system
but is taken by the free memory management facility (cf. garbcoll function).

Example

The following program fragment deallocates memory space that was previously reserved
with malloc.

#include <stdlib.h>
char *buf;
buf = (char *)malloc(100);
    .
    .
free(buf);

See also

malloc, calloc, realloc, garbcoll