The malloc function performs dynamic memory allocation in C and is part of the standard library
C library function for reallocating a dynamically allocated memory region.
Faster memcpy memory
"That s why realloc can temporarily require more memory than a malloc free pair"
from question "Why is realloc eating tons of memory?"
"A realloc can occur significantly faster than a malloc memcpy and free"
from question "Why is there no reallocation functionality in C++ allocators?"
"I mean i think realloc is way smarter so why do we even need malloc"
from question "Why am I getting a segmentation fault when using realloc()?"
"Realloc is worse than malloc in that you will need to have the old and new pointers valid during the realloc"
from question "Is realloc() safe in embedded system?"
"Malloc often gives you more memory that you ask and stores the actual value in a special location that realloc can access at a later time"
from question "Realloc simply not diong anything, not erroring"
"In the case of overflow a free malloc pair costs less than realloc because of its internal hidden memcpy"
from question "Substitute or workaround for asprintf on AIX"
"The justification of realloc is that it s faster than 2nd malloc manual copy free"
from question "C++ realloc performance vs malloc"
"But if it works with large datasets the users will notice that using the malloc -only program slows down other programs much more than the realloc -using program with the same data"
from question "Why should we use `realloc` if we need a `tmp buffer`"