What is the difference between realloc() and free()

Showing Answers 1 - 6 of 6 Answers

dasam

  • Mar 29th, 2007
 

The realloc() function changes the size of the memory object pointed to by ptr to the size specified by sizefree() function deallocates the block of memory previously allocated using a call to malloc, calloc or realloc, making it availbale again for further allocations.

cshaw

  • Mar 31st, 2009
 

The free subroutine frees a block of memory previously allocated by the malloc subroutine. Undefined results occur if the Pointer parameter is not a valid pointer. If the Pointer parameter is a null value, no action will occur.

The realloc subroutine changes the size of the block of memory pointed to by the Pointer parameter to the number of bytes specified by the Size parameter and returns a new pointer to the block. The pointer specified by the Pointer parameter must have been created with the malloc, calloc, or realloc subroutines and not been deallocated with the free or realloc subroutines. Undefined results occur if the Pointer parameter is not a valid pointer

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions