title: How does realloc work on memory allocated using calloc?
body: <p>When we try to resize the memory allocated by <code>malloc</code> using <code>realloc</code>, we typically do this:</p>
  
  <pre><code>char *ptr = (char *)malloc(size_1);
  ptr = (char *)realloc(ptr, size_2);
  </code></pre>
  
  <p>If <code>size_2</code> may be larger or smaller than <code>size_1</code>. If new size is larger then the old data is not lost and newly allocated bytes are uninitialized. The starting address contained by the <code>ptr</code> may change if there is not sufficient memory at the old address to store all bytes consecutively. <code>realloc</code> moves the contents of old block into the new block and <code>ptr</code> will be pointing to the initial byte of this new block.</p>
  
  <p>But, if memory is allocated using <code>calloc</code>, I was not able to understand how <code>realloc</code> function acts. Can someone please give me a brief overview about how <code>realloc</code> works on memory allocated by <code>calloc</code>?</p>