diff options
author | Michael Cardell Widerkrantz <mc@hack.org> | 2011-02-24 07:23:02 +0100 |
---|---|---|
committer | Michael Cardell Widerkrantz <mc@hack.org> | 2011-03-08 12:14:38 +0100 |
commit | 0acf6c27267b63f9e11f0374346e53c423addd14 (patch) | |
tree | 6277951602d0a7db947396c87e39d6ef34cec297 | |
parent | b61c62214ef5fb2d0b1bc5604b74e7dbcd778071 (diff) | |
download | mcwm-0acf6c27267b63f9e11f0374346e53c423addd14.zip |
Bug in movetohead(). Old head needs to be updated with new prev
pointer.
-rw-r--r-- | list.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -23,7 +23,7 @@ void movetohead(struct item **mainlist, struct item *item) if (*mainlist == item) { - /* Already at head. Do nothing. */ + /* item is NULL or we're already at head. Do nothing. */ return; } @@ -38,10 +38,15 @@ void movetohead(struct item **mainlist, struct item *item) item->next->prev = item->prev; } - /* Now at head. */ + /* Now we'at head, so no one before us. */ item->prev = NULL; + + /* Old head is our next. */ item->next = *mainlist; + /* Old head needs to know about us. */ + item->next->prev = item; + /* Remember the new head. */ *mainlist = item; } |