title: Realloc not expanding my array
body: <p>I'm having trouble implementing realloc in a very basic way.</p>
  
  <p>I'm trying to expand the region of memory at **ret, which is pointing to an array of structs
  with <code>ret = realloc(ret, newsize);</code> and based on my debug strings I <em>know</em> newsize is correctly increasing over the course of the loop (going from the original size of 4 to 8 to 12 etc.), but when I do <code>sizeof(ptr)</code> it's still returning the original size of 4, and the things I'm trying to place into the newly allocated space can't be found (I think I've narrowed it down to realloc() which is why I'm formatting the question like this)</p>
  
  <p>I can post the function in it's entirety if the problem isn't immediately evident to you, I'm just trying to not "cheat" with my homework too much (the code is kind of messy right now anyway, with heavy use of printf() for debug).</p>
  
  <p>[EDIT] Alright, so based on your answers I'm failing at debugging my code, so I guess I'll post the whole function so you can tell me more about what I'm doing wrong.</p>
  
  <p>(You can ignore the printf()'s since most of that is debug that isn't even working)</p>
  
  <pre><code> Booking **bookingSelectPaid(Booking **booking)  {
       Booking **ret = malloc(sizeof(Booking*));
       printf("Initial address of ret = %p\n", ret);
       size_t i = 0;
       int numOfPaid = 0;
       while (booking[i] != NULL)
       {
           if (booking[i]-&gt;paid == 1)
           {
               printf("Paying customer! sizeof(Booking*) = %d\n", (int)sizeof(Booking*));
               ++numOfPaid;
               size_t newsize = sizeof(Booking*) * (numOfPaid + 1);
               printf("Newsize = %d\n", (int)newsize);
               Booking **temp = realloc(NULL, (size_t)newsize);
               if (temp != NULL)
                   printf("Expansion success! =&gt; %p sizeof(new pointer) = %d ret = %p\n", temp, (int)sizeof(temp), ret);
               ret = realloc(ret, newsize);
               ret[i] = booking[i];
               ret[i+1] = NULL;
           }
           ++i;
           printf("Sizeof(ret) = %d numOfPaid = %d\n", (int)sizeof(ret), numOfPaid);
       }
       return ret; }
  </code></pre>
  
  <p>[EDIT2] --> <a href="http://pastebin.com/xjzUBmPg" rel="nofollow">http://pastebin.com/xjzUBmPg</a></p>
  
  <p>[EDIT3] Just to be clear, the printf's, the temp pointer and things of that nature are debug, and not part of the intended functionality. The line that is puzzling me is either the one with <code>realloc(ret, newsize);</code> or <code>ret[i] = booking[i]</code></p>
  
  <p>Basically I know for sure that booking contains a table of structs that ends in NULL, and I'm trying to bring the ones that have a specific value set to 1 (paid) onto the new table, which is what my main() is trying to get from this function... So where am I going wrong?</p>