diff --git a/mx_util.c b/mx_util.c index 8b67515..0aea318 100644 --- a/mx_util.c +++ b/mx_util.c @@ -1268,6 +1268,7 @@ int mx_daemon(int nochdir, int noclose) return daemon(nochdir, noclose); } +/* guarantee stable sort */ void _mx_sort_linked_list (void **list, int (*cmp)(void *o1,void *o2), void ** getnextptr(void *o)) { void *unsorted=*list; diff --git a/test_mx_util.c b/test_mx_util.c index 6f47309..20b58c8 100644 --- a/test_mx_util.c +++ b/test_mx_util.c @@ -489,6 +489,7 @@ static void test_listsort(void) } /* (100 0 1 2 50 50 2 1 0 100) -> ( 0 0 1 1 2 2 50 50 100 100) stable */ + /* also verify stable sort */ for (int i=0;i<10;i++) { o[i].next= i==9 ? NULL : &o[i+1]; }