hash hash32 hash32_buf hash32_str hash32_strn hash32_stre hash32_strne - general kernel hashing functions
The
hash32_buf ();
function is used as a general buffer hashing function.
The argument
Fa buf
is used to pass in the location, and
Fa len
is the length of the buffer.
The argument
Fa hash
is used to extend an existing hash, or is passed the initial value
HASHINIT
to start a new hash.
The
hash32_str ();
function is used to hash a
NUL
terminated string passed in
Fa buf
with initial hash value given in
Fa hash .
The
hash32_strn ();
function is like the
hash32_str ();
function, except it also takes a
Fa len
argument, which is the maximal length of the expected string.
The
hash32_stre ();
and
hash32_strne ();
functions are helper functions used by the kernel to hash pathname
components.
These functions have the additional termination condition
of terminating when they find a character given by
Fa end
in the string to be hashed.
If the argument
Fa ep
is not
NULL
it is set to the point in the buffer at which the hash function
terminated hashing.
LIST_HEAD(head, cache) *hashtbl = NULL; u_long mask = 0; void sample_init(void) { hashtbl = hashinit(numwanted, type, flags, &mask); } void sample_use(char *str, int len) { uint32_t hash; hash = hash32_str(str, HASHINIT); hash = hash32_buf(&len, sizeof(len), hash); hashtbl[hash & mask] = len; }
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |