== Code sweeping ==
[blender.git] / source / blender / blenlib / intern / util.c
index 9ababcae39deded76575dd2151a446cc1a2744c4..dc2e53483dba35fc1d907356e67d36b0d820c86b 100644 (file)
@@ -324,9 +324,10 @@ void BLI_sortlist(ListBase *listbase, int (*cmp)(void *, void *))
 
        if (listbase->first != listbase->last)
        {
-               for( previous = listbase->first, current = previous->next; current; previous = current, current = next )
+               for( previous = listbase->first, current = previous->next; current; current = next )
                {
                        next = current->next;
+                       previous = current->prev;
                        
                        BLI_remlink(listbase, current);
                        
@@ -335,14 +336,7 @@ void BLI_sortlist(ListBase *listbase, int (*cmp)(void *, void *))
                                previous = previous->prev;
                        }
                        
-                       if (previous == NULL)
-                       {
-                               BLI_addhead(listbase, current);
-                       }
-                       else
-                       {
-                               BLI_insertlinkafter(listbase, previous, current);
-                       }
+                       BLI_insertlinkafter(listbase, previous, current);
                }
        }
 }