From 644bef12333c1ed88984988991b1a3f9b5b07a60 Mon Sep 17 00:00:00 2001 From: paladin-t Date: Thu, 18 Feb 2016 11:20:41 +0800 Subject: [PATCH] *fixed a wrong list linkage bug with list sorting. --- HISTORY | 1 + core/my_basic.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/HISTORY b/HISTORY index 7bbf171..6a44ebc 100755 --- a/HISTORY +++ b/HISTORY @@ -1,5 +1,6 @@ Feb. 18 2016 Added a generic iterator type +Fixed a wrong list linkage bug with list sorting Feb. 16 2016 Fixed a bug of the EXIT statement with FOR loop diff --git a/core/my_basic.c b/core/my_basic.c index 2f981fa..86b6b2d 100755 --- a/core/my_basic.c +++ b/core/my_basic.c @@ -2159,7 +2159,7 @@ static unsigned int _ls_foreach(_ls_node_t* list, _ls_operation op) { static _ls_node_t* _ls_sort(_ls_node_t** list, _ls_compare cmp) { /* Copyright 2001 Simon Tatham, http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.c */ - bool_t is_circular = false, is_double = false; + bool_t is_circular = false, is_double = true; _ls_node_t* p, * q, * e, * tail, * oldhead; int insize, nmerges, psize, qsize, i; _ls_node_t* lst = 0; @@ -2235,6 +2235,8 @@ static _ls_node_t* _ls_sort(_ls_node_t** list, _ls_compare cmp) { (*list)->next = lst; (*list)->prev = tail; + lst->prev = *list; + return *list; }