Guardian C Library Calls Reference Manual
free
3-58 128833—Guardian TNS C Library Calls Reference Manual
Reference to Library Calls
free
The free function releases a block of memory that you have allocated using calloc,
malloc, or realloc.
blk_ptr
points to the block of memory to release. It must point to the first byte of the block
returned by calloc, malloc, or realloc.
Return Value
none.
Usage Guidelines
•
Attempts to free a block not allocated by calloc, malloc, or realloc cause an error
when detected.
Examples
1. This example frees the block of memory pointed to by blk:
#include <stdlibh>
char *blk;
blk = malloc(100);
free(blk);
2. This example frees the block of memory pointed to by ptr:
#include <stdlibh>
int *ptr;
/* ... */
ptr = (int *)malloc(100);
/* ... */
free(ptr);
/* ... */
#include <stdlibh>
void free(void *blk_ptr);