add hashing to event header lookup

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10227 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale
2008-11-03 20:08:44 +00:00
parent d4087da371
commit 7074c7abdd
5 changed files with 80 additions and 6 deletions
+24
View File
@@ -74,6 +74,30 @@ SWITCH_DECLARE(void) switch_pool_clear(switch_memory_pool_t *p)
apr_pool_clear(p);
}
SWITCH_DECLARE(unsigned int) switch_ci_hashfunc_default(const char *char_key, switch_ssize_t *klen)
{
unsigned int hash = 0;
const unsigned char *key = (const unsigned char *)char_key;
const unsigned char *p;
apr_ssize_t i;
if (*klen == APR_HASH_KEY_STRING) {
for (p = key; *p; p++) {
hash = hash * 33 + tolower(*p);
}
*klen = p - key;
}
else {
for (p = key, i = *klen; i; i--, p++) {
hash = hash * 33 + tolower(*p);
}
}
return hash;
}
SWITCH_DECLARE(unsigned int) switch_hashfunc_default(const char *key, switch_ssize_t *klen)
{
return apr_hashfunc_default(key, klen);