Skip to content

Instantly share code, notes, and snippets.

@scriptum
Last active December 22, 2015 21:29
Show Gist options
  • Save scriptum/6534072 to your computer and use it in GitHub Desktop.
Save scriptum/6534072 to your computer and use it in GitHub Desktop.
string hash from cairo
#define _CAIRO_HASH_INIT_VALUE 5381
unsigned long _cairo_hash_string (const char *c)
{
/* This is the djb2 hash. */
unsigned long hash = _CAIRO_HASH_INIT_VALUE;
while (c && *c)
hash = ((hash << 5) + hash) + *c++;
return hash;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment