On Fri, 2008-09-05 at 07:49 +0200, Henning Rogge wrote:
[...]
> But maybe we can even do it better... we just define that our "comparator" 
> function will return a value less than zero if the first parameter is smaller 
> than the second one, 0 if they are both equal and more than zero if the first 
> parameter is greater than the second one.
> 
> olsr_32_t time_cmp(const olsr_u32_t t1, const olsr_u32_t t2)
> {
>    return t1 - t2;
> }
> 
> We just have to remember this definition when we use the function.

Basically yes (and I can as well live with that).
I purposely normalized it to ==-1/==0/==1 similar to the other function.
And it's not that uncommon since e.g. strcmp() also return s <0/==0/>0.

So it's a question of - to exaggerate a bit;-) - "API design".

That's also why I mentioned the sgn() function which is the
"normalization" part.

	Bernd
-- 
Firmix Software GmbH                   http://www.firmix.at/
mobil: +43 664 4416156                 fax: +43 1 7890849-55
          Embedded Linux Development and Services




