int getmin(int a, int b)
{
return a
malloc
does not initialize memory to zero. (calloc
is the equivalent that does.) If you are seeing things set to zero, it's accidental.
I believe the library version of realloc
uses length information in the heap that is not directly available. (And it may overestimate the original allocation, which means it might copy a little extra memory when using realloc
to expand the allocation. This generally has no effect.)
realloc
likely doesn't do a copy when shrinking an allocation.
Also, I should note that in same cases, you don't have to do a copy even when realloc
increases the size, for example, if the next block in the heap is free.