title: Freeing tree that is NOT binary in C
body: <p>I'm trying to free a tree that is not binary. It includes dozens of leaves and paths.
  Basicly it's a tree that starts with a root of a chess board position, and includes a lot of other positions.
  The structs are the following:</p>
  <pre><code>typedef char chessPos[2];
  typedef struct _treeNodeListCell treeNodeListCell;
  
  
  typedef struct _treeNode
  {
      chessPos position;
      treeNodeListCell* next_possible_positions;
  } treeNode;
  
  typedef struct _treeNodeListCell
  {
      treeNode* node;
      struct _treeNodeListCell* next;
  } treeNodeListCell;
  
  typedef struct _pathTree
  {
      treeNode* root;
  } pathTree;
  </code></pre>
  <p>Basicly I want to free a whole path tree. For example, the path tree looks the following:
  <a href="https://i.stack.imgur.com/mBKQo.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mBKQo.jpg" alt="enter image description here" /></a></p>
  <p>So the root of path tree is the root with &quot;C3&quot; written in it.
  (Ignore the parts with the blue &quot;X&quot; on them, it just means that these tree nodes aren't in the tree in my program)</p>
  <p>This is the way I was trying to free the tree:</p>
  <pre><code>void freePathTree(pathTree* ptr)
  {
      freeTreeNode(ptr-&gt;root);
      free(ptr);
  }
  
  void freeTreeNodeListCell(treeNodeListCell* tmp)
  {
      if (tmp-&gt;next != NULL)
      {
          freeTreeNodeListCell(tmp-&gt;next);
      }
      freeTreeNode(tmp-&gt;node);
      free(tmp);
  }
  
  void freeTreeNode(treeNode* tmp)
  {
      if (tmp-&gt;next_possible_positions == NULL)
          free(tmp);
      else
      {
          freeTreeNodeListCell(tmp-&gt;next_possible_positions);
      }
  }
  </code></pre>
  <p>But as always, when trying to free memory, I receive dozens of warnings.</p>
  <p>How can I free this huge tree without getting any errors? What is wrong with my program?</p>
  <p>Big thanks in advance!</p>