diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-12-22 14:45:27 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-12-22 14:45:27 +0000 |
commit | 91ecd609c1e7e2f9ff5f8c7ea3f44aabc24c139c (patch) | |
tree | bd132d50fdaadb6b845abbb62e3e273d182754e4 /include | |
parent | 83a4b299245d4b0ea76ef2234ef6b4597393c6ce (diff) |
Re-work ref count handling of MoH classes using astobj2 to resolve crashes.
(closes issue #13566)
Reported by: igorcarneiro
Tested by: russell
Review: http://reviewboard.digium.com/r/106/
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@166262 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include')
-rw-r--r-- | include/asterisk/strings.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/asterisk/strings.h b/include/asterisk/strings.h index a7e2fa4ba..c800d532e 100644 --- a/include/asterisk/strings.h +++ b/include/asterisk/strings.h @@ -26,6 +26,7 @@ #include <stdlib.h> #include <string.h> #include <stdarg.h> +#include <ctype.h> #include "asterisk/inline_api.h" #include "asterisk/compiler.h" @@ -282,4 +283,22 @@ static force_inline int ast_str_hash(const char *str) return abs(hash); } +/*! + * \brief Compute a hash value on a case-insensitive string + * + * Uses the same hash algorithm as ast_str_hash, but converts + * all characters to lowercase prior to computing a hash. This + * allows for easy case-insensitive lookups in a hash table. + */ +static force_inline int ast_str_case_hash(const char *str) +{ + int hash = 5381; + + while (*str) { + hash = hash * 33 ^ tolower(*str++); + } + + return abs(hash); +} + #endif /* _ASTERISK_STRINGS_H */ |