summaryrefslogtreecommitdiffhomepage
path: root/src/anonymous.c
diff options
context:
space:
mode:
authorrofl0r <rofl0r@users.noreply.github.com>2020-09-12 21:33:59 +0100
committerrofl0r <rofl0r@users.noreply.github.com>2020-09-15 23:12:00 +0100
commit155bfbbe87daae596d9c77ea3ee9bf9624afcce0 (patch)
treeb9a4f6a05c039dcb9c4ff08de179cc61faeeae72 /src/anonymous.c
parent34a8b28414de419c984f832a299383f6d7149f72 (diff)
replace leftover users of hashmap with htab
also fixes a bug where the ErrorFile directive would create a new hashmap on every added item, effectively allowing only the use of the last specified errornumber, and producing memory leaks on each config reload.
Diffstat (limited to 'src/anonymous.c')
-rw-r--r--src/anonymous.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/anonymous.c b/src/anonymous.c
index f38fd44..91e490c 100644
--- a/src/anonymous.c
+++ b/src/anonymous.c
@@ -23,7 +23,7 @@
#include "main.h"
#include "anonymous.h"
-#include "hashmap.h"
+#include "hsearch.h"
#include "heap.h"
#include "log.h"
#include "conf.h"
@@ -42,7 +42,7 @@ int anonymous_search (struct config_s *conf, const char *s)
assert (s != NULL);
assert (conf->anonymous_map != NULL);
- return hashmap_search (conf->anonymous_map, s);
+ return !!htab_find (conf->anonymous_map, s);
}
/*
@@ -51,23 +51,21 @@ int anonymous_search (struct config_s *conf, const char *s)
* Return -1 if there is an error, otherwise a 0 is returned if the insert was
* successful.
*/
-int anonymous_insert (struct config_s *conf, const char *s)
+int anonymous_insert (struct config_s *conf, char *s)
{
- char data = 1;
-
assert (s != NULL);
if (!conf->anonymous_map) {
- conf->anonymous_map = hashmap_create (32);
+ conf->anonymous_map = htab_create (32);
if (!conf->anonymous_map)
return -1;
}
- if (hashmap_search (conf->anonymous_map, s) > 0) {
- /* The key was already found, so return a positive number. */
+ if (htab_find (conf->anonymous_map, s)) {
+ /* The key was already found. */
return 0;
}
/* Insert the new key */
- return hashmap_insert (conf->anonymous_map, s, &data, sizeof (data));
+ return htab_insert (conf->anonymous_map, s, HTV_N(1)) ? 0 : -1;
}