commented early_printk patch because of rejects.
[linux-flexiantxendom0-3.2.10.git] / security / selinux / ss / symtab.c
1 /*
2  * Implementation of the symbol table type.
3  *
4  * Author : Stephen Smalley, <sds@epoch.ncsc.mil>
5  */
6 #include "symtab.h"
7
8 static unsigned int symhash(struct hashtab *h, void *key)
9 {
10         char *p, *keyp;
11         unsigned int size;
12         unsigned int val;
13
14         val = 0;
15         keyp = key;
16         size = strlen(keyp);
17         for (p = keyp; (p - keyp) < size; p++)
18                 val = (val << 4 | (val >> (8*sizeof(unsigned int)-4))) ^ (*p);
19         return val & (h->size - 1);
20 }
21
22 static int symcmp(struct hashtab *h, void *key1, void *key2)
23 {
24         char *keyp1, *keyp2;
25
26         keyp1 = key1;
27         keyp2 = key2;
28         return strcmp(keyp1, keyp2);
29 }
30
31
32 int symtab_init(struct symtab *s, unsigned int size)
33 {
34         s->table = hashtab_create(symhash, symcmp, size);
35         if (!s->table)
36                 return -1;
37         s->nprim = 0;
38         return 0;
39 }
40