la funzione in cui si verifica l'errore è la seguente:
le deallocazioni di cui parlavo prima sono quelle in calce al programma.
	codice:
	// calculate_routing: Calculate the minimum path for each couple of source-destination nodes
void calculate_routing(NETINFO_PTR netinfo_ptr, LISTNODEPTR adiacence_array, PATH* routing_array, 
					   LISTNODEPTR path_array, STATENODE** nodeinfo_mtx) 
{
  int i, j, num, back;
  enum stop_condition {TRUE, FALSE} stop;
  LISTNODEPTR current = malloc(sizeof(LISTNODE));
  LISTNODEPTR swapptr = malloc(sizeof(LISTNODE));
  LISTNODEPTR cur_adiacence = malloc(sizeof(LISTNODE));
  LISTNODEPTR actual_list = malloc(sizeof(LISTNODE));
  current = NULL; 
  cur_adiacence = NULL;
  stop = FALSE;
  actual_list = listnode_init();
        
  swapptr = listnode_init();
  //-- nodes initialization ---------------------
  for (i = 0; i <= netinfo_ptr->size->COUPLE_NUM - 1; i++) 
  {  
	for(j = 0; j <= netinfo_ptr->size->NNODES - 1; j++)
	 {
      nodeinfo_mtx[j][i].predecessor = INIT_PRED;
	  nodeinfo_mtx[j][i].precedent = INIT_PRED;
	  if(j == routing_array[i].source)
	  {
	    nodeinfo_mtx[j][i].hop_number = 0;
	    nodeinfo_mtx[j][i].label = permanent;
	  }
	  else
	  {
		nodeinfo_mtx[j][i].hop_number = INFINITY;
	    nodeinfo_mtx[j][i].label = tentative;
	  }
	 }
    routing_array[i].length = 0;
    listnode_insert(actual_list, routing_array[i].source);
    listnode_insert(&path_array[i], routing_array[i].source); 
    
    num = 0;
    while (stop != TRUE) 
	{
      current = actual_list;
      while (current != NULL && stop != TRUE) 
	  {
	    cur_adiacence = &adiacence_array[current->node];
	
	     while (cur_adiacence != NULL && stop != TRUE) 
		 {
	       if (nodeinfo_mtx[cur_adiacence->node][i].label == tentative) 
		   {
	         nodeinfo_mtx[cur_adiacence->node][i].label = permanent;
	         nodeinfo_mtx[cur_adiacence->node][i].hop_number = num;
	         nodeinfo_mtx[cur_adiacence->node][i].predecessor = current->node;
	         listnode_insert(swapptr, cur_adiacence->node);
	         if (cur_adiacence->node == routing_array[i].destination) 
			 {
	            stop = TRUE;
	            back = routing_array[i].destination;
	            while (back != routing_array[i].source)
				{
		           nodeinfo_mtx[back][i].precedent = nodeinfo_mtx[back][i].predecessor;
		           listnode_insert(&path_array[i], back);
	  	           back = nodeinfo_mtx[back][i].predecessor;
				}
	      
	            listnode_insert(&path_array[i],routing_array[i].source);
			 }
		   }
	       cur_adiacence = cur_adiacence->nextnode_ptr;
		 }
       	 current = current->nextnode_ptr;
      }
      
      listnode_free(actual_list);
      actual_list = listnode_init();
     
      if (stop != TRUE)
	  listnode_copy(swapptr, actual_list); 
		 
      listnode_free(swapptr);
      
      swapptr = listnode_init();
      
      num++;
    }
    routing_array[i].length = num;
    stop = FALSE;
  }
//  free(current);
  free(swapptr);
  free(cur_adiacence);
//  free(actual_list);
}