title: realloc return null
body: <p>I have a simple program, for learning purposes, yet I keep on getting null returned when I realloc from allocated array.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  #include &lt;stdlib.h&gt;
  
  
  void main() 
  {
      char *ptr, *retval;
  
      ptr = (char *)calloc(10, sizeof(char));
  
      if (ptr == NULL)
          printf("calloc failed\n");
      else
          printf("calloc successful\n");
  
      retval = (char *)realloc(ptr, 5);
  
      if (retval == NULL)
          printf("realloc failed\n");    
      else
          printf("realloc successful\n");
  
      free(ptr);
      free(retval);
  
  }
  </code></pre>
  
  <p>I'm not able to realloc, <code>retval = (char *)realloc(ptr, 5);</code>
  what am I doing wrong?</p>