aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/sort.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/sort.c b/src/sort.c
index 0f9b93d..c5ba091 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -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;

Return to:

Send suggestions and report system problems to the System administrator.