title: Invalid reads, writes and frees
body: <p>I got a lot of write, read and free errors. I don't know where is mistake. If someone could help me out with this I'd be grateful. Here is log from valgrind: <br />
  <a href="http://pastebin.com/TR4Ts73Y" rel="nofollow">http://pastebin.com/TR4Ts73Y</a></p>
  
  <pre><code>void deleteElement(element* node) {
  element* child;
  if (node == NULL)
      return;
  
  free(node-&gt;name);
  
  if (node-&gt;text != NULL)
      free(node-&gt;text);
  
  child = node-&gt;firstChild;
  while(child != NULL)
  {
      deleteElement(child);
      child = child-&gt;nextSibling;
  }
  
  free(node);
  }
  </code></pre>
  
  <p>If you need more functions feel free to ask for.</p>