Re:Out-of-bounds read and write in the glibc's qsort()
by sureglymop on Monday February 05, 2024 @02:48PM
(#39266103)
Then what is a better alternative? I was always told that I shouldn't implement something as trivial as sorting algorithms by myself...
[ Parent
| on HN ]
Re:Out-of-bounds read and write in the glibc's qsort()
by tokedo on Monday February 05, 2024 @05:34PM
(#39268168)
A simple solution is to create a C++ file and exposing sorting functions to C. E.g. "void sort_int(int *data, size_t n)". The implementation uses then std::sort.
Unfortunately, qsort is really slow and sometimes barely usable.
Re:Out-of-bounds read and write in the glibc's qsort()
by CyberDildonics on Tuesday February 06, 2024 @10:17AM
(#39275084)
You were told correctly, but there is a lot of room between using the C standard library and making your own sort. C++ STL std::sort is one, but the internet is filled with libraries you can download, of course you can find a better alternative with a search.