Project

General

Profile

Download (620 Bytes) Statistics
| Branch: | Tag: | Revision:
/**
* Copyright © 2019, Oracle and/or its affiliates. All rights reserved.
*
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl
*
*/
#ifndef HASHFUN_H
#define HASHFUN_H
#include <stddef.h>

static size_t hash_init(void) { return 0; }
static size_t hash_add(size_t oldhash, size_t c) { return oldhash*11 + c; }
static size_t hash_end(size_t hash) { return (hash>>13) + hash; }
static size_t hash_string(const char *name) {
size_t r = hash_init();
while (*name) {
r = hash_add(r, (unsigned char)*name++);
}
return hash_end(r);
}
#endif
(9-9/29)