/* We have our own local lfind() equivalent to avoid subtle differences in types passed to lfind() on different systems.  */
static void* td_lfind(const void *key, const void *base, size_t *nmemb, size_t size, int(*compar)(const void *, const void *))
/* We have our own local lfind() equivalent to avoid subtle differences in types passed to lfind() on different systems.  */
static void* td_lfind(const void *key, const void *base, size_t *nmemb, size_t size, int(*compar)(const void *, const void *))
{
    char *element, *end;
    end = (char *)base + *nmemb * size;
    for (element = (char *)base; element < end; element += size)
        if (!compar(key, element))
            return element;
    return NULL;
}