File: njs_djb_hash.c

package info (click to toggle)
libnginx-mod-js 0.9.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,300 kB
  • sloc: ansic: 124,113; perl: 9,084; javascript: 2,717; exp: 487; sh: 322; xml: 312; python: 181; makefile: 18
file content (44 lines) | stat: -rw-r--r-- 628 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44

/*
 * Copyright (C) Igor Sysoev
 * Copyright (C) NGINX, Inc.
 */


#include <njs_main.h>


uint32_t
njs_djb_hash(const void *data, size_t len)
{
    uint32_t      hash;
    const u_char  *p;

    p = data;
    hash = NJS_DJB_HASH_INIT;

    while (len != 0) {
        hash = njs_djb_hash_add(hash, *p++);
        len--;
    }

    return hash;
}


uint32_t
njs_djb_hash_lowcase(const void *data, size_t len)
{
    uint32_t      hash;
    const u_char  *p;

    p = data;
    hash = NJS_DJB_HASH_INIT;

    while (len != 0) {
        hash = njs_djb_hash_add(hash, njs_lower_case(*p++));
        len--;
    }

    return hash;
}