• René Scharfe's avatar
    compat: add qsort_s() · 04ee8b87
    René Scharfe authored
    The function qsort_s() was introduced with C11 Annex K; it provides the
    ability to pass a context pointer to the comparison function, supports
    the convention of using a NULL pointer for an empty array and performs a
    few safety checks.
    Add an implementation based on compat/qsort.c for platforms that lack a
    native standards-compliant qsort_s() (i.e. basically everyone).  It
    doesn't perform the full range of possible checks: It uses size_t
    instead of rsize_t and doesn't check nmemb and size against RSIZE_MAX
    because we probably don't have the restricted size type defined.  For
    the same reason it returns int instead of errno_t.
    Signed-off-by: default avatarRene Scharfe <l.s.r@web.de>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
qsort_s.c 1.33 KB