Table of Contents Previous topic Next topic
C LIBRARY FUNCTIONS->Detailed Descriptions->free()
void free(void* ptr); Free a block of allocated memory
ptr Pointer to allocated memory block
This function de-allocates a memory block which has previously been allocated through a call to malloc(). The parameter ptr is the pointer to the memory block and is in fact the pointer value that was returned by the original call to malloc(). The number of bytes de-allocated is the same as
that allocated in the original malloc() call.
After the block has been freed by this call, then the memory is again available for allocation.
There is no return value.
Note that there is no check that the ptr is a valid pointer to a memory block allocated by malloc() and if an invalid pointer is used then the memory pointer to is still added to the free memory pool. This may result in the corruption of memory if it is allocated in a subsequent call to malloc().