| 887 | */ |
| 888 | |
| 889 | static TARGETS * make0sort( TARGETS * chain ) |
| 890 | { |
| 891 | PROFILE_ENTER( MAKE_MAKE0SORT ); |
| 892 | |
| 893 | TARGETS * result = 0; |
| 894 | |
| 895 | /* Walk the current target list. */ |
| 896 | while ( chain ) |
| 897 | { |
| 898 | TARGETS * c = chain; |
| 899 | TARGETS * s = result; |
| 900 | |
| 901 | chain = chain->next; |
| 902 | |
| 903 | /* Find point s in result for c. */ |
| 904 | while ( s && timestamp_cmp( &s->target->time, &c->target->time ) > 0 ) |
| 905 | s = s->next; |
| 906 | |
| 907 | /* Insert c in front of s (might be 0). */ |
| 908 | c->next = s; /* good even if s = 0 */ |
| 909 | if ( result == s ) result = c; /* new head of chain? */ |
| 910 | if ( !s ) s = result; /* wrap to ensure a next */ |
| 911 | if ( result != c ) s->tail->next = c; /* not head? be prev's next */ |
| 912 | c->tail = s->tail; /* take on next's prev */ |
| 913 | s->tail = c; /* make next's prev us */ |
| 914 | } |
| 915 | |
| 916 | PROFILE_EXIT( MAKE_MAKE0SORT ); |
| 917 | return result; |
| 918 | } |
| 919 | |
| 920 | |
| 921 | static LIST * targets_to_update_ = L0; |
no test coverage detected