/* Hash an F_triple, and *do* consider the file name. */ size_t triple_hash (void const *x, size_t table_size) { struct F_triple const *p = x; size_t tmp = hash_pjw (p->name, table_size); /* Ignoring the device number here should be fine. */ return (tmp ^ p->st_ino) % table_size; }
/* * entry_hashcode * -------------------- * * INPUT: pointer to entry read to be hashed * OUTPUT: size_t hash of the read name * */ size_t entry_hashcode(const void *elt) { size_t hashcode; // DLOG("entry_hashcode()"); const entry *bbr = elt; /* get uid */ char* uid = bbr->key; // DLOG("entry_hashcode: calling hash_pjw on uid=[%s]", uid); hashcode = hash_pjw(uid, BRINDLEY_TABLESIZE); // DLOG("bbr_hashcode: have hashcode=[%zu] for uid=[%s] tablesize=[%zu]", hashcode, uid, BRINDLEY_TABLESIZE); // DLOG("bbr_hashcode: returning hashcode=[%zu]", hashcode); return hashcode; }
/* Hash an F_triple. */ static unsigned int triple_hash (void const *x, unsigned int table_size) { struct F_triple const *p = x; /* Also take the name into account, so that when moving N hard links to the same file (all listed on the command line) all into the same directory, we don't experience any N^2 behavior. */ /* FIXME-maybe: is it worth the overhead of doing this just to avoid N^2 in such an unusual case? N would have to be very large to make the N^2 factor noticable, and one would probably encounter a limit on the length of a command line before it became a problem. */ unsigned int tmp = hash_pjw (p->name, table_size); /* Ignoring the device number here should be fine. */ return (tmp | p->st_ino) % table_size; }
static size_t dir_cache_hash (void const *x, size_t table_size) { struct dir_cache const *p = x; return hash_pjw (p->path, table_size); }
static size_t entry_hash (void const *x, size_t table_size) { struct entry const *p = x; return hash_pjw (p->name, table_size); }
static size_t hasher (void const *x, size_t table_size) { struct pda_entry const *p = x; return hash_pjw (p->key, table_size); }
static size_t gen_hash (void const *x, size_t table_size) { struct entry_common const *p = x; return hash_pjw (p->pathname, table_size); }
void makeFullPath( char *topdir, char *out, size_t outlen, const char *filename ) { unsigned int h = hash_pjw(filename); snprintf( out, outlen, "%s/%02x/%02x/%s", topdir, h%0xff, (h/256)%0xff, filename ); }