On Wed, Oct 26, 2022 at 8:54 AM Jonathan Leffler <jonathan.leffler@gmail.com> wrote:
However, I think that TZ code can sidestep the whole issue by using:
if (nlinks > 1) qsort(links, nlinks, sizeof(*links), qsort_linkcmp);
There's no need to sort arrays of size 0 or 1. This avoids any questions about whether a count of zero is valid as an argument to qsort().
Of course, I assume here that links will never be null when nlinks is 1 or more — the only time links could possibly be null is if nlinks is 0. If there are other circumstances where links could be null, you could add to the condition: if (nlinks > 1 && links != NULL) qsort(links, nlinks, sizeof(*links), qsort_linkcmp); -- Jonathan Leffler <jonathan.leffler@gmail.com> #include <disclaimer.h> Guardian of DBD::Informix - v2018.1031 - http://dbi.perl.org "Blessed are we who can laugh at ourselves, for we shall never cease to be amused."