Ignore:
Timestamp:
Jul 19, 2010, 2:44:24 PM (13 years ago)
Author:
charles
Message:

(trunk libT) #3427 "use shortest-job-first scheduling for verifying local data" -- patch from wateenellende and sadface

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/list.c

    r10524 r11023  
    145145}
    146146
     147void
     148tr_list_insert_sorted( tr_list            ** list,
     149                       void                * data,
     150                       TrListCompareFunc     compare )
     151{
     152    /* find l, the node that we'll insert this data before */
     153    tr_list * l;
     154
     155    for( l = *list; l != NULL; l = l->next )
     156    {
     157        const int c = (compare)( data, l->data );
     158        if( c <= 0 )
     159            break;
     160    }
     161
     162    if( l == NULL )
     163        tr_list_append( list, data );
     164    else if( l == *list )
     165        tr_list_prepend( list, data );
     166    else {
     167        tr_list * node = node_alloc( );
     168        node->data = data;
     169        node->prev = l->prev;
     170        node->next = l;
     171        node->prev->next = node;
     172        node->next->prev = node;
     173    }
     174}
     175
    147176int
    148177tr_list_size( const tr_list * list )
Note: See TracChangeset for help on using the changeset viewer.