title: Function free() in C isn't working for me
body: <p>I have been trying to free memory allocated via <code>malloc()</code> using <code>free()</code>.</p>
  
  <p>Some of the structs it does free but leaves some the way they were and they also remain linked to their children. It also never frees the root <code>(gRootPtr)</code> for a binary tree.</p>
  
  <p>I am using Xcode to find out if the memory used by the binary tree has been freed and also use the if statement.</p>
  
  <p>Code I am using to free the memory:</p>
  
  <pre><code>void FreeMemory(InfoDefiner *InfoCarrier)
  {
      if ((*InfoCarrier) != NULL) {
          FreeMemory((&amp;(*InfoCarrier)-&gt;left));
          FreeMemory((&amp;(*InfoCarrier)-&gt;right));
          free((*InfoCarrier));
      }
  }
  </code></pre>
  
  <p>Code I am using to see if the memory has been freed.</p>
  
  <pre><code>if (gRootPtr != NULL) {
      return 1;
  }
  else{
      return 0;
  }
  </code></pre>