This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: qsort_r argument order


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
3rd one.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]