/*
* 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.8 2002/12/26 13:16:54 alex Exp $";
+/**
+ * @file
+ * Hash calculation
+ */
#include "imp.h"
#include <assert.h>
#include <string.h>
#include "defines.h"
-#include "log.h"
#include "tool.h"
#include "exp.h"
#include "hash.h"
-LOCAL 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 ));
GLOBAL UINT32
-Hash( CHAR *String )
+Hash( const char *String )
{
/* Hash-Wert ueber String berechnen */
- CHAR buffer[LINE_LEN];
+ char buffer[LINE_LEN];
- strncpy( buffer, String, LINE_LEN - 1 );
- buffer[LINE_LEN - 1] = '\0';
-
- 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 */
} /* mix */
-LOCAL UINT32
+static UINT32
jenkins_hash( register UINT8 *k, register UINT32 length, register UINT32 initval )
{
/* k: the key
/* handle the last 11 bytes */
c += length;
- switch( (INT)len ) /* all the case statements fall through */
+ switch( (int)len ) /* all the case statements fall through */
{
case 11: c+=((UINT32)k[10]<<24);
case 10: c+=((UINT32)k[9]<<16);