ho risolto da solo. il problema è che memorizzavo i puntatori e quindi rimaneva sempre il solito:
ecco il codice aggironato se servisse a qualcuno:
Codice PHP:
/* Metodo per aggiungere un lemma e le sue statistiche alla lista */
struct lemma_cell *add(struct lemma_cell *lista, char *lemma, int l, int row){
struct lemma_cell *new_cell;
if (lista != NULL){
new_cell = (struct lemma_cell *)malloc(sizeof(struct lemma_cell));
new_cell->row = row;
new_cell->n = 1;
new_cell->l = l;
new_cell->lemma = (char *)malloc(l*sizeof(char));
strcpy(new_cell->lemma, lemma);
new_cell->next = lista;
}else{
lista = (struct lemma_cell *)malloc(sizeof(struct lemma_cell));
lista->row = row;
lista->n = 1;
lista->l = l;
lista->lemma = (char *)malloc(l*sizeof(char));
strcpy(lista->lemma, lemma);
lista->next = NULL;
new_cell = lista;
}
return(new_cell);
}