title: 'Empty tree' function causing program to crash
body: <p>I have a empty_tree() function that basically returns a true value if the tree is empty and returns false if it is not.</p>
  
  <pre><code>bool empty_tree(AVL self)
  {
      if (self == NULL)
      {
          return true;
      }
      else
      {
          return false;
      }
  }
  </code></pre>
  
  <p>It exists so that my program is easier to understand without comments. Now, it works fine everywhere else in my program. However when I try and use it in my insert function in place of the working:</p>
  
  <pre><code>if(self == NULL)
  </code></pre>
  
  <p>my program will crash. This isn't really a big deal and using the 'if (self==NULL) will suffice, but I was just wondering if anyone had any ideas as to why this would cause the program to crash. As I said, it's not extremely important so I won't bother including more code, but if anyone had any guesses, I'd appreciate hearing your thoughts.</p>
  
  <p><strong>EDIT:</strong> Upon request, here's where the section that works:</p>
  
  <pre><code>if (self == NULL)
      {
          self = (AVL)malloc(sizeof(struct avlNode));
          self-&gt;student_id = id;
          self-&gt;left = self-&gt;right = NULL;
      }
  </code></pre>
  
  <p>And here's the code that will, when changed to this, crash the program:</p>
  
  <pre><code>if (!empty_tree(self))
      {
          self = (AVL)malloc(sizeof(struct avlNode));
          self-&gt;student_id = id;
          self-&gt;left = self-&gt;right = NULL;
      }
  </code></pre>