util-hash.c File Reference
#include "suricata-common.h"
#include "util-hash.h"
#include "util-unittest.h"
#include "util-memcmp.h"
Include dependency graph for util-hash.c:

Go to the source code of this file.


HashTableHashTableInit (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)
void HashTablePrint (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)

Detailed Description

Victor Julien

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 responsebility

Definition in file util-hash.c.

Function Documentation

◆ HashTableAdd()

◆ HashTableDefaultCompare()

char HashTableDefaultCompare ( void *  data1,
uint16_t  len1,
void *  data2,
uint16_t  len2 

Definition at line 238 of file util-hash.c.

References SCMemcmp.

Referenced by HashTableInit().

Here is the caller graph for this function:

◆ HashTableFree()

void HashTableFree ( HashTable ht)

◆ HashTableGenericHash()

uint32_t HashTableGenericHash ( HashTable ht,
void *  data,
uint16_t  datalen 

Definition at line 221 of file util-hash.c.

References HashTable_::array_size.

◆ HashTableInit()

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 34 of file util-hash.c.

References HashTable_::array, HashTable_::array_size, HashTable_::Compare, HashTable_::Free, HashTable_::Hash, HashTableDefaultCompare(), SCFree, SCMalloc, and unlikely.

Referenced by DetectMetadataHashInit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HashTableLookup()

void* HashTableLookup ( HashTable ht,
void *  data,
uint16_t  datalen 

◆ HashTablePrint()

void HashTablePrint ( HashTable ht)

Definition at line 105 of file util-hash.c.

References HashTable_::array_size, and HashTable_::Hash.

◆ HashTableRegisterTests()

void HashTableRegisterTests ( void  )

Definition at line 427 of file util-hash.c.

References UtRegisterTest().

Here is the call graph for this function:

◆ HashTableRemove()

int HashTableRemove ( HashTable ht,
void *  data,
uint16_t  datalen