This is the mail archive of the
mailing list for the glibc project.
Re: qsort_r argument order
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Dustin Lang <dstn at cs dot toronto dot edu>
- Cc: libc-alpha at sourceware dot org
- Date: Wed, 3 Dec 2008 15:58:42 +0100
- Subject: Re: qsort_r argument order
- References: <Pine.LNX.email@example.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Tue, Dec 02, 2008 at 12:22:10PM -0500, Dustin Lang wrote:
> I suppose this comment is coming too late, but I really wish that the
> qsort_r function had been done differently. As far as I can tell, qsort_r
Yes, it is too late.
> is not part of any standard, but it exists in BSD (including Mac OSX).
> For some reason that I can't comprehend, when it was added to glibc the
> argument order was permuted.
But looking at the BSD version, it couldn't be designed worse.
Passing the caller provided argument as first instead of 3rd argument
means that e.g. you have to have 2 implementations of qsort*.
In glibc qsort can be (and is) implemented as
qsort_r (base, nmemb, size, (void *) callback, NULL)
and at least on all arches I'm aware of a function expecting 2 pointer
arguments can be called with 3 pointer arguments and just doesn't see the