title: What is the point of using a temporary realloc variable, if the program will exit?
body: <p>Many people recommend doing the following to reallocate memory:</p>
  <pre><code>int *temp=realloc(previousVar,newSize);
  if(temp==NULL){
   printf(&quot;error\n&quot;);
   exit(-1);
  }
  previousVar=temp;
  </code></pre>
  <p>I understand that, if no new variable was created, the previous pointer would be lost, as <code>NULL</code> would be assigned to it. But what's the point on having all this trouble, if the program will exit in case of failure anyways?</p>
  <p>Here's a stack overflow, where the top answer has what I'm referring to:
  <a href="https://stackoverflow.com/questions/21006707/proper-usage-of-realloc">Proper usage of realloc()</a></p>