title: I figured out how to write realloc, but I know the code is not right?
body: <p>What I decided to do is</p>
  
  <ul>
  <li>call malloc </li>
  <li>copy the old block to the new block</li>
  <li>free the old block </li>
  <li>and return the pointer to the new block</li>
  </ul>
  
  <p>The code below is what I have so far...but I know it is not right...any help on fixing the code would be greatly appreciated...</p>
  
  <p>If you need more code than what I have provided I have a post previous to this one which shows all the code.  I'm new so there is only this post and the last post I have done.
  Thank You.</p>
  
  <pre><code>void *mm_realloc(void *ptr, size_t size)
  {
  int i, p = *ptr;
  
   // make a call to malloc to find space
   //allocate memory
  
   ptr = malloc(size_t*sizeof(int));
  
   //copying old block to new block
   if(ptr!=NULL)
       for(i=0 ; i&lt;size_t ; i++) 
       {
       *(ptr+i) = i;
       }
  
  //freeing old block
  free(ptr);
  
  //return pointer to new block
  return *ptr;
  }
  </code></pre>