summaryrefslogtreecommitdiff
path: root/dmake/hash.c
blob: a172995656bad151f691c88f80205640a5b11947 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* RCS  $Id: hash.c,v 1.2 2006-09-25 09:39:55 vg Exp $
--
-- SYNOPSIS
--      Hashing function for hash tables.
--
-- DESCRIPTION
--      Hash an identifier.  The hashing function works by computing the sum
--      of each char and the previous hash value multiplied by 129.  Finally the
--      length of the identifier is added in.  This way the hash depends on the
--      chars as well as the length, and appears to be sufficiently unique,
--      and is FAST to COMPUTE, unlike the previous hash function...
--
-- AUTHOR
--      Dennis Vadura, dvadura@dmake.wticorp.com
--
-- WWW
--      http://dmake.wticorp.com/
--
-- COPYRIGHT
--      Copyright (c) 1996,1997 by WTI Corp.  All rights reserved.
--
--      This program is NOT free software; you can redistribute it and/or
--      modify it under the terms of the Software License Agreement Provided
--      in the file <distribution-root>/readme/license.txt.
--
-- LOG
--      Use cvs log to obtain detailed change logs.
*/

#include "extern.h"

PUBLIC uint16
Hash( id, phv )/*
=================
      This function computes the identifier's hash value and returns the hash
      value modulo the key size as well as the full hash value.  The reason
      for returning both is so that hash table searches can be sped up.  You
      compare hash keys instead and compare strings only for those whose 32-bit
      hash keys match. (not many) */

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) );
}

0000'>2017-02-13Fix typosAndrea Gelmini 2017-02-03TyposJulien Nabet 2017-02-03TyposJulien Nabet 2017-02-03Typo about "property"Julien Nabet 2017-01-24AccStatisticsObject is apparently dead codeStephan Bergmann 2017-01-21coverity#1399435 Unused valueCaolán McNamara 2017-01-21coverity#1399443 UrF: Unread fieldCaolán McNamara 2017-01-21coverity#1399442 UPM: Private method is never calledCaolán McNamara 2017-01-21coverity#1399444 UwF: Unwritten fieldCaolán McNamara 2017-01-21this.cmdLine assigned twiceCaolán McNamara 2017-01-17cid#1398822: java.util.Properties.getProperty already returns StringStephan Bergmann 2017-01-17remove some unused Java codeNoel Grandin 2017-01-16qadevOOo: remove silly exception catching from util.FormToolsMichael Stahl 2017-01-16forms,qadevOOo: dispatch of .uno:SwitchControlDesignMode is asyncMichael Stahl 2017-01-16boil down the use of OPERATING_SYSTEM to its unorc/uno.ini useCaolán McNamara 2017-01-04SwXAutoTextEntry needs a disposal protocolStephan Bergmann 2016-12-31Dispose XWindow when doneStephan Bergmann 2016-12-12update png locations for various imagelist unwindingsCaolán McNamara 2016-12-07Fix typo in comments: et -> edTakeshi Abe 2016-10-27Add link to bug describing such a raceStephan Bergmann 2016-10-27untabifyStephan Bergmann