From 5598223d9cd3f14c00aa82bd14e424147449f796 Mon Sep 17 00:00:00 2001 From: irfan Date: Mon, 18 May 1998 21:54:25 +0000 Subject: *** empty log message *** --- ace/ACE.cpp | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'ace/ACE.cpp') diff --git a/ace/ACE.cpp b/ace/ACE.cpp index f3310f4e1ab..9849395f268 100644 --- a/ace/ACE.cpp +++ b/ace/ACE.cpp @@ -314,13 +314,14 @@ ACE::execname (const wchar_t *old_name) #endif /* ACE_HAS_UNICODE */ u_long -ACE::hash_pjw (const char *str) +ACE::hash_pjw (const char *str, size_t len) { u_long hash = 0; - for (const char *temp = str; *temp != 0; temp++) + for (size_t i = 0; i < len; i++) { - hash = (hash << 4) + (*temp * 13); + const char temp = str[i]; + hash = (hash << 4) + (temp * 13); u_long g = hash & 0xf0000000; @@ -335,13 +336,20 @@ ACE::hash_pjw (const char *str) } u_long -ACE::hash_pjw (const ACE_USHORT16 *str) +ACE::hash_pjw (const char *str) +{ + return ACE::hash_pjw (str, ACE_OS::strlen (str)); +} + +u_long +ACE::hash_pjw (const ACE_USHORT16 *str, size_t len) { u_long hash = 0; - for (const ACE_USHORT16 *temp = str; *temp != 0; temp++) + for (size_t i = 0; i < len; i++) { - hash = (hash << 4) + (*temp * 13); + const ACE_USHORT16 temp = str[i]; + hash = (hash << 4) + (temp * 13); u_long g = hash & 0xf0000000; @@ -355,6 +363,12 @@ ACE::hash_pjw (const ACE_USHORT16 *str) return hash; } +u_long +ACE::hash_pjw (const ACE_USHORT16 *str) +{ + return ACE::hash_pjw (str, ACE_OS::strlen (str)); +} + // The CRC routine was taken from the FreeBSD implementation of cksum, // that falls under the following license: /*- -- cgit v1.2.1