void destroy_list(struct LList* list){ while(list->count > 0){ struct LLNode* node = pop(list); destroy_llnode(node); } free(list); list = NULL; }
void destroy_list(list* l) { if (l == NULL) { puts("l är null"); return; } linked_list_node* ll_node = l -> ll_first; linked_list_node* tmp_ll_node = NULL; while (ll_node != NULL) { tmp_ll_node = ll_node; ll_node = ll_node -> next_node; destroy_llnode(tmp_ll_node); } if (l != NULL) free(l); }
void remove_shelf(node* n, shelf* shelf) { list* l = get_list(n); linked_list_node* prev = get_prev_node(l, shelf); linked_list_node* remove; if (prev == NULL) { remove = l -> ll_first; l -> ll_first = remove -> next_node; } else { remove = prev -> next_node; linked_list_node* next = remove -> next_node; prev -> next_node = next; } int r_amount = get_shelf_amount2(remove); l -> total = l -> total - r_amount; destroy_llnode(remove); }