hey, can anyone figure out why this insert function is setting all nodes in the list to have the same item?
-
void insert_list (list_ref list, list_item item) {
-
listnode_ref new = malloc (sizeof (struct listnode));
-
assert (is_list (list));
-
assert (new != NULL);
-
new->tag = listnode_tag;
-
new->item = item;
-
if (list->head == NULL) {
-
list->head = new;
-
list->last = new;
-
list->curr = new;
-
}else{
-
new->prev = list->last;
-
list->last->next = new;
-
list->last = new;
-
list->curr = new;
-
};
-
}
-
i cant figure it out for the life of me. other than that problem it seems to be working fine - it creates a new node and sticks it on the list, and it appears that the links work, too. any help would be GREATLY appreciated.. i've been trying to figure this out for like 2 hours -_- i think i must be missing something obvious, but i have no idea what. i know for sure the problem has to be in this function, though (after a LOT of debug prints to pinpoint it).