suricata
util-hash.h
Go to the documentation of this file.
1/* Copyright (C) 2007-2010 Open Information Security Foundation
2 *
3 * You can copy, redistribute or modify this Program under the terms of
4 * the GNU General Public License version 2 as published by the Free
5 * Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * version 2 along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 */
17
18/**
19 * \file
20 *
21 * \author Victor Julien <victor@inliniac.net>
22 */
23
24#ifndef SURICATA_HASH_H
25#define SURICATA_HASH_H
26
27/* hash bucket structure */
28typedef struct HashTableBucket_ {
29 void *data;
30 uint16_t size;
33
34/* hash table structure */
35typedef struct HashTable_ {
37 uint32_t array_size;
38#ifdef UNITTESTS
39 uint32_t count;
40#endif
41 uint32_t (*Hash)(struct HashTable_ *, void *, uint16_t);
42 char (*Compare)(void *, uint16_t, void *, uint16_t);
43 void (*Free)(void *);
45
46#define HASH_NO_SIZE 0
47
48/* prototypes */
49HashTable* HashTableInit(uint32_t, uint32_t (*Hash)(struct HashTable_ *, void *, uint16_t), char (*Compare)(void *, uint16_t, void *, uint16_t), void (*Free)(void *));
51int HashTableAdd(HashTable *, void *, uint16_t);
52int HashTableRemove(HashTable *, void *, uint16_t);
53void *HashTableLookup(HashTable *, void *, uint16_t);
54void HashTableIterate(HashTable *ht, void (*CallbackFn)(void *, void *), void *aux);
55uint32_t HashTableGenericHash(HashTable *, void *, uint16_t);
56char HashTableDefaultCompare(void *, uint16_t, void *, uint16_t);
57
58void HashTableRegisterTests(void);
59
60#endif /* SURICATA_HASH_H */
uint16_t size
Definition util-hash.h:30
struct HashTableBucket_ * next
Definition util-hash.h:31
char(* Compare)(void *, uint16_t, void *, uint16_t)
Definition util-hash.h:42
HashTableBucket ** array
Definition util-hash.h:36
uint32_t count
Definition util-hash.h:39
uint32_t array_size
Definition util-hash.h:37
void(* Free)(void *)
Definition util-hash.h:43
uint32_t(* Hash)(struct HashTable_ *, void *, uint16_t)
Definition util-hash.h:41
int HashTableRemove(HashTable *, void *, uint16_t)
Definition util-hash.c:142
struct HashTable_ HashTable
char HashTableDefaultCompare(void *, uint16_t, void *, uint16_t)
Definition util-hash.c:243
uint32_t HashTableGenericHash(HashTable *, void *, uint16_t)
Definition util-hash.c:226
void HashTableRegisterTests(void)
Definition util-hash.c:432
HashTable * HashTableInit(uint32_t, uint32_t(*Hash)(struct HashTable_ *, void *, uint16_t), char(*Compare)(void *, uint16_t, void *, uint16_t), void(*Free)(void *))
Definition util-hash.c:35
void HashTableIterate(HashTable *ht, void(*CallbackFn)(void *, void *), void *aux)
Definition util-hash.c:212
struct HashTableBucket_ HashTableBucket
void * HashTableLookup(HashTable *, void *, uint16_t)
Definition util-hash.c:183
int HashTableAdd(HashTable *, void *, uint16_t)
Definition util-hash.c:104
void HashTableFree(HashTable *)
Definition util-hash.c:78