/* remove node form list */ void list_remove_data(List * L, void * data) { List *p, *tmpcell; p = list_find_prev( L , data ); if ( !list_is_last( p ) ) { /* data is found; delete it */ tmpcell = p->next; p->next = tmpcell->next; /* Bypass deleted cell */ free( tmpcell ); } else { if ( L->next == NULL ) { L->data = NULL; return; } else { /*swap 1st and 2st*/ p = list_get_first_entry( L ); tmpcell = p->next; p->data = tmpcell->data; if (!p->next->next) p->next = NULL; else p->next = tmpcell->next; free( tmpcell ); } } }
void list_elm_del(list_t l, element_t e) { position_t p = list_find_prev(l, e); if (!list_is_last_elm(l, p)) { position_t t = p->next; p->next = t->next; free(t); } return; }