diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/sort.c | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -95,13 +95,15 @@ _qsort_nodelist(struct node_list *list, cur = next; } - /* Sort both sublists recursively */ - _qsort_nodelist(&low_list, compare); - _qsort_nodelist(&high_list, compare); - - /* Join both lists in order */ - node_list_join(&low_list, &high_list); - + if (!low_list.head) + low_list = high_list; + else if (high_list.head) { + /* Sort both sublists recursively */ + _qsort_nodelist(&low_list, compare); + _qsort_nodelist(&high_list, compare); + /* Join both lists in order */ + node_list_join(&low_list, &high_list); + } /* Return the resulting list */ list->head = low_list.head; list->tail = low_list.tail; |