title: Free function activates a breakpoint
body: <p>I'm trying to call the free function to deallocate nodes from a linked list, but whenever I try to do so the IDE (CLion) stops the program and gives me a SIGTRAP (Trace/breakpoint trap).</p>
  <p>Here is the linked list:</p>
  <pre><code>struct node{
      int score;
      int index;
      struct node* nextNode;
  };
  
  typedef struct node* List;
  </code></pre>
  <p>Now the functions that initalizes and links the list:</p>
  <pre><code>List list= malloc(sizeof(List));
  list-&gt;index=-1;
  list-&gt;score=-10;
  list-&gt;next=NULL;
  min++;  min--;
  List temp;
  for(int i=sizeGrafi-1; i&gt;0; i--){
       temp= malloc(sizeof(List));
       temp-&gt;index=i;
       temp-&gt;score=-10;
       temp-&gt;next=list;
       nodiDaVisitare=temp;
  }
  </code></pre>
  <p>And here's the funcition that should delete and deallocate a node (to avoid useless code I'll
  just post the case in which the node to remove is the head):</p>
  <pre><code>List removeNode(List list){
      Lista temp= malloc(sizeof(List));
      temp=list;
      list=list-&gt;next;
      free(temp);
      return list;
  }
  </code></pre>
  <p>I tried looking at similiar questions, but I couldn't find what is wrong with my code. The crash happens when the free function gets called.</p>
  <p>EDIT: I followed the advice to remove the typedef</p>
  <pre><code>typedef struct node* List;
  </code></pre>
  <p>,rewrite all lists as Node*, with Node defined as:</p>
  <pre><code>typedef struct node{
      int punteggio;
      int indice;
      struct nodo* successivo;
  }Node;
  </code></pre>
  <p>and using the right size (i.e. sizeof(Node)) in mallocs.
  Now the function free doesn't seem to give any problems. Thank you all.</p>