this is not a conformance issue as posix does not specify the
argument order, but the order is specified for bsearch and some
systems document the order for lsearch consistently (openbsd).
since there were two indpendent reports of this issue it's better
to use the more widely expected argument order.
size_t i;
for (i = 0; i < n; i++)
- if (compar(p[i], key) == 0)
+ if (compar(key, p[i]) == 0)
return p[i];
*nelp = n+1;
return memcpy(p[n], key, width);
size_t i;
for (i = 0; i < n; i++)
- if (compar(p[i], key) == 0)
+ if (compar(key, p[i]) == 0)
return p[i];
return 0;
}