X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fngircd%2Fhash.c;h=113133d20c7f75019b35297aba13904cf32e4c79;hb=c26ca7773bfc92ca41344a0994bee45ec917b261;hp=3bf2417fd146027d7ed2e147c9bd3e15ae122cea;hpb=77f54693ef258b1fe65ee105fc026dfb2c6257dc;p=ngircd-alex.git diff --git a/src/ngircd/hash.c b/src/ngircd/hash.c index 3bf2417f..113133d2 100644 --- a/src/ngircd/hash.c +++ b/src/ngircd/hash.c @@ -1,20 +1,20 @@ /* * ngIRCd -- The Next Generation IRC Daemon - * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de) + * Copyright (c)2001-2010 Alexander Barton (alex@barton.de) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * Please read the file COPYING, README and AUTHORS for more information. - * - * Hash calculation */ - #include "portab.h" -static char UNUSED id[] = "$Id: hash.c,v 1.12 2005/07/31 20:13:08 alex Exp $"; +/** + * @file + * Hash calculation + */ #include "imp.h" #include @@ -26,35 +26,37 @@ static char UNUSED id[] = "$Id: hash.c,v 1.12 2005/07/31 20:13:08 alex Exp $"; #include "exp.h" #include "hash.h" +static UINT32 jenkins_hash PARAMS((register UINT8 *k, register UINT32 length, + register UINT32 initval)); -static UINT32 jenkins_hash PARAMS(( register UINT8 *k, register UINT32 length, register UINT32 initval )); - - +/** + * Calculate hash value for a given string. + * + * @param String Input string + * @return 32 bit hash value + */ GLOBAL UINT32 -Hash( char *String ) +Hash( const char *String ) { - /* Hash-Wert ueber String berechnen */ - char buffer[LINE_LEN]; - strlcpy( buffer, String, sizeof( buffer )); - return jenkins_hash( (UINT8 *)ngt_LowerStr( buffer ), strlen( buffer ), 42 ); + strlcpy(buffer, String, sizeof(buffer)); + return jenkins_hash((UINT8 *)ngt_LowerStr(buffer), + (UINT32)strlen(buffer), 42); } /* Hash */ - /* - * Die hier verwendete Hash-Funktion stammt aus lookup2.c von Bob Jenkins - * (URL: ). Aus dem Header: + * This hash function originates from lookup2.c of Bob Jenkins + * (URL: ): * -------------------------------------------------------------------- * lookup2.c, by Bob Jenkins, December 1996, Public Domain. * hash(), hash2(), hash3, and mix() are externally useful functions. * Routines to test the hash are included if SELF_TEST is defined. * You can use this free for any purpose. It has no warranty. * -------------------------------------------------------------------- - * nicht alle seiner Funktionen werden hier genutzt. + * Not all of his functions are used here. */ - #define hashsize(n) ((UINT32)1<<(n)) #define hashmask(n) (hashsize(n)-1) @@ -71,7 +73,6 @@ Hash( char *String ) c -= a; c -= b; c ^= (b>>15); \ } /* mix */ - static UINT32 jenkins_hash( register UINT8 *k, register UINT32 length, register UINT32 initval ) { @@ -121,5 +122,4 @@ jenkins_hash( register UINT8 *k, register UINT32 length, register UINT32 initval return c; } /* jenkins_hash */ - /* -eof- */