title: Why NULL ing pointer before using it in realloc function?
body: <p>If i do the following with <code>malloc</code></p>
  
  <pre><code>HashTableEntry *util = malloc(sizeof(HashTableEntry) * T-&gt;capacity);
  </code></pre>
  
  <p>all works well. However if i do the following with <code>realloc</code></p>
  
  <pre><code>HashTableEntry *util = realloc(util, sizeof(HashTableEntry) * T-&gt;capacity);
  </code></pre>
  
  <p><code>realloc</code> returns <code>NULL</code>. I also get a warning by gcc, saying that i haven't initialized <code>util</code> before using it.</p>
  
  <p>But, the following works perfectly well, like <code>malloc</code></p>
  
  <pre><code>HashTableEntry *util = NULL;
  util = realloc(util, sizeof(HashTableEntry) * T-&gt;capacity);
  </code></pre>
  
  <p>My question is why? </p>
  
  <p>What i believe is happening is that, in all cases, i am creating a pointer and assigning to it the starting address of a block of heap memory i am allocating. Am i wrong somewhere?</p>