void * list_t_remove(list_t *list, void *element, int (*compare)(void *, void *)) { void *previous = NULL; node_t *node; node_t *tmp = list->first; if(NULL != tmp) do { if(compare(tmp->next->element, element)) { node = tmp->next; if(list->first == node) if(node->next == node) list->first = NULL; else list->first = node->next; tmp->next = node->next; previous = (NULL == node) ? node : node->element; node_t_delete(node); list->length--; break; } tmp = tmp->next; } while(list->first != tmp); return previous; }
void node_t_delete_r(NODE_T *node) { int i; for(i=0; i<node->nxtnum; i++) { node_t_delete_r(node->nxt[i]); } node_t_delete(node); }
void * list_t_remove_at(list_t *list, size_t index) { void *element = NULL; node_t *node; node_t *tmp = list->first; if(NULL != tmp) { while(list->first != tmp->next && --index) { tmp = tmp->next; } node = tmp->next; if(list->first == node) if(node->next == node) list->first = NULL; else list->first = node->next; tmp->next = node->next; element = (NULL == node) ? node : node->element; node_t_delete(node); list->length--; } return element; }