Well, if you're already using qsort_r, what's the point of using nested functions, if you can have a context pointer with the target?
And if you're not using qsort_r, but reaching for _Thread_local, the target can be _Thread_local instead of dsq.
And if you're not using qsort_r, but reaching for _Thread_local, the target can be _Thread_local instead of dsq.