X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fmisc.c;h=052509f6f914e8afd9f25985d05f62ef70349a13;hb=f6bcc10ce7b517f04eb5cddf01c9ec29ee729b7e;hp=c02d392067f81401ad910a666f72da1eb9e196f8;hpb=a8cefb9b52499f69c69ae796db7f057b4c76b0db;p=rocksndiamonds.git diff --git a/src/libgame/misc.c b/src/libgame/misc.c index c02d3920..052509f6 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -1965,6 +1965,10 @@ void addNodeToList(ListNode **node_first, char *key, void *content) node_new->key = getStringCopy(key); node_new->content = content; node_new->next = *node_first; + + if (*node_first) + (*node_first)->prev = node_new; + *node_first = node_new; } @@ -1977,8 +1981,15 @@ void deleteNodeFromList(ListNode **node_first, char *key, if (strEqual((*node_first)->key, key)) { checked_free((*node_first)->key); + if (destructor_function) destructor_function((*node_first)->content); + + if ((*node_first)->next) + (*node_first)->next->prev = (*node_first)->prev; + + checked_free(*node_first); + *node_first = (*node_first)->next; } else