aboutsummaryrefslogtreecommitdiff
path: root/example/ndpiReader.c
diff options
context:
space:
mode:
authorToni <matzeton@googlemail.com>2022-06-17 19:50:31 +0200
committerGitHub <noreply@github.com>2022-06-17 19:50:31 +0200
commit9c8b2d63dafc526ff3f0872e8e88e67f72d875d1 (patch)
treeb71901c710a90ecaa115213960b5ffb7ed636317 /example/ndpiReader.c
parent20a29c393f5cff3864a75070b2988fe1be1c6d17 (diff)
Replaced nDPI's internal hashmap with uthash. (#1602)
Signed-off-by: lns <matzeton@googlemail.com>
Diffstat (limited to 'example/ndpiReader.c')
-rw-r--r--example/ndpiReader.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c
index 4ec3a528f..9fa63c8bf 100644
--- a/example/ndpiReader.c
+++ b/example/ndpiReader.c
@@ -4553,20 +4553,24 @@ void rsiUnitTest() {
/* *********************************************** */
void hashUnitTest() {
- ndpi_str_hash *h = ndpi_hash_alloc(16384);
- char* dict[] = { "hello", "world", NULL };
+ ndpi_str_hash *h;
+ char * const dict[] = { "hello", "world", NULL };
int i;
- assert(h);
+ assert(ndpi_hash_init(&h) == 0);
+ assert(h == NULL);
for(i=0; dict[i] != NULL; i++) {
- u_int8_t l = strlen(dict[i]), v;
+ u_int8_t l = strlen(dict[i]);
+ int * v;
- assert(ndpi_hash_add_entry(h, dict[i], l, i) == 0);
- assert(ndpi_hash_find_entry(h, dict[i], l, &v) == 0);
+ assert(ndpi_hash_add_entry(&h, dict[i], l, &i) == 0);
+ assert(ndpi_hash_find_entry(h, dict[i], l, (void **)&v) == 0);
+ assert(v == (void *)&i && *v == i);
}
- ndpi_hash_free(h);
+ ndpi_hash_free(&h, NULL);
+ assert(h == NULL);
}
/* *********************************************** */