suricata
|
#include "suricata-common.h"
#include "util-hash.h"
#include "util-unittest.h"
#include "util-memcmp.h"
#include "util-debug.h"
Go to the source code of this file.
Functions | |
HashTable * | HashTableInit (uint32_t size, uint32_t(*Hash)(struct HashTable_ *, void *, uint16_t), char(*Compare)(void *, uint16_t, void *, uint16_t), void(*Free)(void *)) |
void | HashTableFree (HashTable *ht) |
int | HashTableAdd (HashTable *ht, void *data, uint16_t datalen) |
int | HashTableRemove (HashTable *ht, void *data, uint16_t datalen) |
void * | HashTableLookup (HashTable *ht, void *data, uint16_t datalen) |
uint32_t | HashTableGenericHash (HashTable *ht, void *data, uint16_t datalen) |
char | HashTableDefaultCompare (void *data1, uint16_t len1, void *data2, uint16_t len2) |
void | HashTableRegisterTests (void) |
Chained hash table implementation
The 'Free' pointer can be used to have the API free your hashed data. If it's NULL it's the callers responsibility
Definition in file util-hash.c.
int HashTableAdd | ( | HashTable * | ht, |
void * | data, | ||
uint16_t | datalen | ||
) |
Definition at line 104 of file util-hash.c.
References HashTable_::array, HashTable_::array_size, HashTable_::count, HashTableBucket_::data, HashTable_::Hash, HashTableBucket_::next, SCCalloc, SCFree, SCLogWarning, HashTableBucket_::size, and unlikely.
Referenced by SCRConfAddReference().
char HashTableDefaultCompare | ( | void * | data1, |
uint16_t | len1, | ||
void * | data2, | ||
uint16_t | len2 | ||
) |
Definition at line 228 of file util-hash.c.
References SCMemcmp.
Referenced by HashTableInit().
void HashTableFree | ( | HashTable * | ht | ) |
Definition at line 78 of file util-hash.c.
References HashTable_::array, HashTable_::array_size, HashTableBucket_::data, HashTable_::Free, HashTableBucket_::next, and SCFree.
Referenced by DetectEngineThreadCtxDeinit(), DetectMetadataHashFree(), LogFileFreeCtx(), SCClassConfDeInitContext(), and SCRConfDeInitContext().
uint32_t HashTableGenericHash | ( | HashTable * | ht, |
void * | data, | ||
uint16_t | datalen | ||
) |
Definition at line 211 of file util-hash.c.
References HashTable_::array_size.
HashTable* HashTableInit | ( | uint32_t | size, |
uint32_t(*)(struct HashTable_ *, void *, uint16_t) | Hash, | ||
char(*)(void *, uint16_t, void *, uint16_t) | Compare, | ||
void(*)(void *) | Free | ||
) |
Definition at line 35 of file util-hash.c.
References HashTable_::array, HashTable_::array_size, HashTable_::Compare, HashTable_::Free, HashTable_::Hash, HashTableDefaultCompare(), SCCalloc, SCFree, and unlikely.
Referenced by DetectMetadataHashInit(), and SCLogOpenThreadedFile().
void* HashTableLookup | ( | HashTable * | ht, |
void * | data, | ||
uint16_t | datalen | ||
) |
Definition at line 183 of file util-hash.c.
References HashTable_::array, HashTable_::array_size, HashTable_::Compare, HashTableBucket_::data, HashTable_::Hash, HashTableBucket_::next, SCLogWarning, and HashTableBucket_::size.
Referenced by SCClassConfGetClasstype(), SCGetProtoByName(), SCRConfAddReference(), and SCRConfGetReference().
void HashTableRegisterTests | ( | void | ) |
Definition at line 417 of file util-hash.c.
References UtRegisterTest().
int HashTableRemove | ( | HashTable * | ht, |
void * | data, | ||
uint16_t | datalen | ||
) |
Definition at line 142 of file util-hash.c.
References HashTable_::array, HashTable_::Compare, HashTableBucket_::data, HashTable_::Free, HashTable_::Hash, HashTableBucket_::next, SCFree, and HashTableBucket_::size.