free function
free is used to return allocated memory to the system.
Library: sdlib.h
Prototype: void free(void *s);
Syntax: char *StrPtr;
StrPtr = (char *) malloc(100);
free(StrPtr);
Notes:
- If you use malloc inside a loop and dont free
the memory, you run the risk of the program crashing.
- If a program ends without issuing a free, any allocated memory
is returned to the system.
Examples:
example
program.
See Also:
malloc function.
new C++ replacement for malloc.
delete C++ replacement for free.
Martin Leslie