Whoops, it's not quite that easy - fixed bug in SDL_ClearDirtyRects()
authorSam Lantinga <slouken@libsdl.org>
Sat, 11 Aug 2007 21:42:36 +0000
changeset 2224 29cc9e9c76bd
parent 2223 175754591a13
child 2225 3bca1b7ca25b
Whoops, it's not quite that easy - fixed bug in SDL_ClearDirtyRects()
src/video/SDL_rect.c
--- a/src/video/SDL_rect.c	Sat Aug 11 21:34:08 2007 +0000
+++ b/src/video/SDL_rect.c	Sat Aug 11 21:42:36 2007 +0000
@@ -149,7 +149,20 @@
 void
 SDL_ClearDirtyRects(SDL_DirtyRectList * list)
 {
-    list->free = list->list;
+    SDL_DirtyRect *prev, *curr;
+
+    /* Skip to the end of the free list */
+    prev = NULL;
+    for (curr = list->free; curr; curr = curr->next) {
+        prev = curr;
+    }
+
+    /* Add the list entries to the end */
+    if (prev) {
+        prev->next = list->list;
+    } else {
+        list->free = list->list;
+    }
     list->list = NULL;
     list->count = 0;
 }