mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-24 13:12:03 +00:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user