title: I'm getting a seg fault from the following code. I think it has something to do with my function call?
body: <p>This code is supposed to count all nodes using a wrapper function. This is for a circular linked list, so i'm pointing to rear->next with temp and then traverse with temp until temp ==rear.</p>
  
  <pre class="lang-cpp prettyprint-override"><code>int count_all(node *rear) {
      int count = 0;
      if (!rear)
          return 0;
      if (rear == rear-&gt;next)
          return 1;
      return recursive_count_all(rear,count);
  }
  
  int recursive_count_all(node *rear,int &amp;count)  {
      if (!rear)
          return 0;
  
      node * temp = rear-&gt;next; 
  
      if (rear == temp)
          return 1;
      else
          temp = temp-&gt;next;
  
      return recursive_count_all(rear-&gt;next, ++count);
  }
  </code></pre>