static int cmp_name(const void *p1, const void *p2) { const struct dir_entry *e1 = *(const struct dir_entry **)p1; const struct dir_entry *e2 = *(const struct dir_entry **)p2; return cache_name_compare(e1->name, e1->len, e2->name, e2->len); }
static int cmp_cache_name_compare(const void *a_, const void *b_) { const struct cache_entry *ce1, *ce2; ce1 = *((const struct cache_entry **)a_); ce2 = *((const struct cache_entry **)b_); return cache_name_compare(ce1->name, ce1->ce_flags, ce2->name, ce2->ce_flags); }
int cache_name_pos(const char *name, int namelen) { int first, last; first = 0; last = active_nr; while (last > first) { int next = (last + first) >> 1; struct cache_entry *ce = active_cache[next]; int cmp = cache_name_compare(name, namelen, ce->name, htons(ce->ce_flags)); if (!cmp) return next; if (cmp < 0) { last = next; continue; } first = next+1; } return -first-1; }