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 */
28 typedef struct HashTableBucket_ {
29  void *data;
30  uint16_t size;
33 
34 /* hash table structure */
35 typedef 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 */
49 HashTable* HashTableInit(uint32_t, uint32_t (*Hash)(struct HashTable_ *, void *, uint16_t), char (*Compare)(void *, uint16_t, void *, uint16_t), void (*Free)(void *));
50 void HashTableFree(HashTable *);
51 int HashTableAdd(HashTable *, void *, uint16_t);
52 int HashTableRemove(HashTable *, void *, uint16_t);
53 void *HashTableLookup(HashTable *, void *, uint16_t);
54 uint32_t HashTableGenericHash(HashTable *, void *, uint16_t);
55 char HashTableDefaultCompare(void *, uint16_t, void *, uint16_t);
56 
57 void HashTableRegisterTests(void);
58 
59 #endif /* SURICATA_HASH_H */
HashTableGenericHash
uint32_t HashTableGenericHash(HashTable *, void *, uint16_t)
Definition: util-hash.c:211
HashTableAdd
int HashTableAdd(HashTable *, void *, uint16_t)
Definition: util-hash.c:104
HashTableDefaultCompare
char HashTableDefaultCompare(void *, uint16_t, void *, uint16_t)
Definition: util-hash.c:228
HashTableLookup
void * HashTableLookup(HashTable *, void *, uint16_t)
Definition: util-hash.c:183
HashTable_
Definition: util-hash.h:35
HashTableBucket_::size
uint16_t size
Definition: util-hash.h:30
HashTable_::array_size
uint32_t array_size
Definition: util-hash.h:37
HashTableBucket_
Definition: util-hash.h:28
HashTable_::Compare
char(* Compare)(void *, uint16_t, void *, uint16_t)
Definition: util-hash.h:42
HashTableBucket
struct HashTableBucket_ HashTableBucket
HashTableRemove
int HashTableRemove(HashTable *, void *, uint16_t)
Definition: util-hash.c:142
HashTable_::array
HashTableBucket ** array
Definition: util-hash.h:36
HashTableBucket_::next
struct HashTableBucket_ * next
Definition: util-hash.h:31
HashTable_::count
uint32_t count
Definition: util-hash.h:39
HashTable
struct HashTable_ HashTable
HashTableInit
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
HashTableBucket_::data
void * data
Definition: util-hash.h:29
HashTableRegisterTests
void HashTableRegisterTests(void)
Definition: util-hash.c:417
HashTableFree
void HashTableFree(HashTable *)
Definition: util-hash.c:78
HashTable_::Free
void(* Free)(void *)
Definition: util-hash.h:43
HashTable_::Hash
uint32_t(* Hash)(struct HashTable_ *, void *, uint16_t)
Definition: util-hash.h:41