]> git.ipfire.org Git - thirdparty/git.git/commit - Makefile
compat: add qsort_s()
authorRené Scharfe <l.s.r@web.de>
Sun, 22 Jan 2017 17:51:11 +0000 (18:51 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 23 Jan 2017 19:02:34 +0000 (11:02 -0800)
commit04ee8b875b96c096c479132adca02fa734c3fa96
treec9a761273a585248192544fd8dca35d0e678aada
parentad36dc8b4b165bf9eb3576b42a241164e312d48c
compat: add qsort_s()

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: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Makefile
compat/qsort_s.c [new file with mode: 0644]
git-compat-util.h