Source
xxxxxxxxxx
/*
** Zabbix
** Copyright (C) 2001-2025 Zabbix SIA
**
** 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.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
typedef unsigned char uchar;
/*
* Bob Jenkins hash function (see http://burtleburtle.net/bob/hash/evahash.html)
*/
zbx_hash_t zbx_hash_lookup2(const void *data, size_t len, zbx_hash_t seed)
{
const uchar *p = (const uchar *)data;
zbx_hash_t a, b, c;
a = b = 0x9e3779b9u;
c = seed;
while (len >= 12)
{
a = a + (p[0] + ((zbx_hash_t)p[1] << 8) + ((zbx_hash_t)p[2] << 16) + ((zbx_hash_t)p[3] << 24));
b = b + (p[4] + ((zbx_hash_t)p[5] << 8) + ((zbx_hash_t)p[6] << 16) + ((zbx_hash_t)p[7] << 24));
c = c + (p[8] + ((zbx_hash_t)p[9] << 8) + ((zbx_hash_t)p[10] << 16) + ((zbx_hash_t)p[11] << 24));
mix(a, b, c);
p += 12;
len -= 12;
}
c = c + (zbx_hash_t)len;