Subject: Re: qsort problems
To: None <netbsd-help@NetBSD.ORG, wulf@ping.net.au>
From: Peter Seebach <seebs@solon.com>
List: netbsd-help
Date: 11/07/1996 14:01:15
You must define the comparison function, as the prototype says, as
	int comparison(const void *v1, const void *v2) {...}
and, if you want to convert the pointers, you must do so inside the
function; for instance, the first line might well be
	TTY_NODE **arg1 = v1, **arg2 = v2;
...

In short, qsort() will be calling its 4th argument as though it were
of type 'int (*)(const void *, const void *)', and trying to pass it
a pointer to a function of any other type invokes undefined behavior.

(BTW, you'll need to cast away const in the above line, or declare
the TTY_NODE **'s as appropriately const.)

-s