Difference between realloc() and free?

Answer Posted / praviss

An existing block of memory which was allocated by malloc() subroutine, will be freed by free() subroutine. In case , an invalid pointer parameter is passed, unexpected results will occur. If the parameter is a null pointer, then no action will occur.
Where as the realloc() subroutine allows the developer to change the block size of the memory which was pointed to by the pointer parameter, to a specified bytes size through size parameter and a new pointer to the block is returned. The pointer parameter specified must have been created by using malloc(),calloc() or realloc() sub routines and should not deallocated with realloc() or free() subroutines. If the pointer parameter is a null pointer, then no action will occur.

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How Do you Code Composition and Aggregation in C++ ?

24196


What is coupling in oops?

598


when to use 'mutable' keyword and when to use 'const cast' in c++

1644


What is the difference between procedural programming and oops?

555


What is the highest level of cohesion?

579






What are the 4 main oop principles?

685


How to hide the base class functionality in Inheritance?

638


Why do while loop is used?

577


What is this pointer in oop?

557


What is oops?what is its use in software engineering?

557


Where is pseudocode used?

565


What is the real time example of encapsulation?

597


What are the three parts of a simple empty class?

1460


What is difference between data abstraction and encapsulation?

617


What does no cap mean?

592