Coverage Report

Created: 2025-08-03 06:32

/src/selinux/libsepol/src/symtab.c
Line
Count
Source (jump to first uncovered line)
1
2
/* Author : Stephen Smalley, <stephen.smalley.work@gmail.com> */
3
4
/* FLASK */
5
6
/*
7
 * Implementation of the symbol table type.
8
 */
9
10
#include <string.h>
11
12
#include "private.h"
13
14
#include <sepol/policydb/hashtab.h>
15
#include <sepol/policydb/symtab.h>
16
17
ignore_unsigned_overflow_
18
static unsigned int symhash(hashtab_t h, const_hashtab_key_t key)
19
297M
{
20
297M
  unsigned int hash = 5381;
21
297M
  unsigned char c;
22
23
9.95G
  while ((c = *(unsigned const char *)key++))
24
9.66G
    hash = ((hash << 5) + hash) ^ c;
25
26
297M
  return hash & (h->size - 1);
27
297M
}
28
29
static int symcmp(hashtab_t h
30
      __attribute__ ((unused)), const_hashtab_key_t key1,
31
      const_hashtab_key_t key2)
32
245M
{
33
245M
  return strcmp(key1, key2);
34
245M
}
35
36
int symtab_init(symtab_t * s, unsigned int size)
37
16.2M
{
38
16.2M
  s->table = hashtab_create(symhash, symcmp, size);
39
16.2M
  if (!s->table)
40
0
    return -1;
41
16.2M
  s->nprim = 0;
42
16.2M
  return 0;
43
16.2M
}
44
45
void symtab_destroy(symtab_t * s)
46
0
{
47
0
  if (!s)
48
0
    return;
49
0
  if (s->table)
50
0
    hashtab_destroy(s->table);
51
0
  return;
52
0
}
53
/* FLASK */