xant / libhl

Simple and fast C library implementing a thread-safe API to manage hash-tables, linked lists, lock-free ring buffers and queues
GNU Lesser General Public License v3.0
420 stars 117 forks source link

Add new sort function: list_qsort and add complicated test cases #7

Closed gnuemacs closed 9 years ago

gnuemacs commented 9 years ago

Current list_sort has bug in it, which will result in infinite recursions and generate Segmentation Fault, it turns out that some edge condition is not handled properly.

Besides, current list_sort is really hard to understand.

While the new quick sort (list_qsort) is easy to understand and bug-free, and it's a bit slower only the data set is small, otherwise it's not slower than current in-place version.

And the test cases are really simple, so I devise some complicated ones.