Skip to content

Commit

Permalink
INTEGRATION: CWS dmake46 (1.1.1.1.152); FILE MERGED
Browse files Browse the repository at this point in the history
2006/07/22 03:48:48 vq 1.1.1.1.152.1: #i10000# Add some comments.
  • Loading branch information
vg committed Sep 25, 2006
1 parent 92df759 commit 7cdb0bd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions hash.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* 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
-- Hashing function for hash tables.
Expand Down Expand Up @@ -38,15 +38,17 @@ Hash( id, phv )/*
compare hash keys instead and compare strings only for those whose 32-bit
hash keys match. (not many) */

char *id;
uint32 *phv;
char *id; /* value */
uint32 *phv; /* key */
{
register char *p = id;
register uint32 hash = (uint32) 0;

while( *p ) hash = (hash << 7) + hash + (uint32) (*p++);
*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) );
}

0 comments on commit 7cdb0bd

Please sign in to comment.