+ 7

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

1st May 2017, 3:18 AM
sadiya zainab
sadiya zainab - avatar
2 Respuestas
+ 8
1] 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. 2] 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.
1st May 2017, 3:26 AM
Sandeep Balachandran
Sandeep Balachandran - avatar
0
hello 👋… my friend
8th Jul 2017, 12:35 PM
bzhzbzg