Kaydet (Commit) db56d412 authored tarafından Vladimir Glazounov's avatar Vladimir Glazounov

INTEGRATION: CWS dmake46 (1.1.1.1.152); FILE MERGED

2006/07/22 03:48:48 vq 1.1.1.1.152.1: #i10000# Add some comments.
üst 8149ed2a
/* RCS $Id: hash.c,v 1.1.1.1 2000-09-22 15:33:25 hr Exp $ /* RCS $Id: hash.c,v 1.2 2006-09-25 09:39:55 vg Exp $
-- --
-- SYNOPSIS -- SYNOPSIS
-- Hashing function for hash tables. -- Hashing function for hash tables.
...@@ -38,8 +38,8 @@ Hash( id, phv )/* ...@@ -38,8 +38,8 @@ Hash( id, phv )/*
compare hash keys instead and compare strings only for those whose 32-bit compare hash keys instead and compare strings only for those whose 32-bit
hash keys match. (not many) */ hash keys match. (not many) */
char *id; char *id; /* value */
uint32 *phv; uint32 *phv; /* key */
{ {
register char *p = id; register char *p = id;
register uint32 hash = (uint32) 0; register uint32 hash = (uint32) 0;
...@@ -47,6 +47,8 @@ uint32 *phv; ...@@ -47,6 +47,8 @@ uint32 *phv;
while( *p ) hash = (hash << 7) + hash + (uint32) (*p++); while( *p ) hash = (hash << 7) + hash + (uint32) (*p++);
*phv = hash = hash + (uint32) (p-id); *phv = hash = hash + (uint32) (p-id);
/* return an index (for Macs[]) where all keys with the same remainder
* after integer division with HASH_TABLE_SIZE are stored. */
return( (uint16) (hash % HASH_TABLE_SIZE) ); return( (uint16) (hash % HASH_TABLE_SIZE) );
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment