Changeset 11023 for trunk/libtransmission/list.c
- Timestamp:
- Jul 19, 2010, 2:44:24 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/list.c
r10524 r11023 145 145 } 146 146 147 void 148 tr_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 147 176 int 148 177 tr_list_size( const tr_list * list )
Note: See TracChangeset
for help on using the changeset viewer.