title: Sysmalloc: Assertion
body: <blockquote>
    <p>main: malloc.c:2405: sysmalloc: Assertion `(old_top == initial_top (av) &amp;&amp; old_size == 0) || ((unsigned long) (old_size) >= MINSIZE &amp;&amp; prev_inuse (old_top) &amp;&amp; ((unsigned long) old_end &amp; (pagesize - 1)) == 0)' failed.  </p>
  </blockquote>
  
  <p>When trying to produce a doubly linked list where the user can only add to the head or tail, I end up getting the lovely abortion message at the top. </p>
  
  <p>I have used gdb to narrow it down to what function it is that is causing this, but I really don't know what I'm doing wrong. It allocates the first node, then after that, it throws me the error.<br>
  The function is as follows:</p>
  
  <pre><code>data* initD(){
      data *D = NULL;
  
      D = malloc(sizeof(data*));
      if (!D){
          printf("Error in allocation of data\n");
          exit(0);
      }
  
      D-&gt;head = NULL;
      D-&gt;tail = NULL;
      D-&gt;next = NULL;
      D-&gt;prev = NULL;
      D-&gt;val = -1;
  
      return D; 
  }
  </code></pre>