summaryrefslogtreecommitdiffhomepage
path: root/src/anonymous.c
diff options
context:
space:
mode:
authorrofl0r <rofl0r@users.noreply.github.com>2020-01-15 16:09:41 +0000
committerrofl0r <rofl0r@users.noreply.github.com>2020-01-15 16:09:41 +0000
commitc63d5d26b47b44d70af54aa31f811e4815fe4ad9 (patch)
tree7f2709f94c4249c7f6b8cce4087680faf4ba7bee /src/anonymous.c
parentbffa70500562f0ed675ed8d7e2385925c25f14fc (diff)
access config via a pointer, not a hardcoded struct address
this is required so we can elegantly swap out an old config for a new one in the future and remove lots of boilerplate from config initialization code. unfortunately this is a quite intrusive change as the config struct was accessed in numerous places, but frankly it should have been done via a pointer right from the start. right now, we simply point to a static struct in main.c, so there shouldn't be any noticeable changes in behaviour.
Diffstat (limited to 'src/anonymous.c')
-rw-r--r--src/anonymous.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/anonymous.c b/src/anonymous.c
index 3049acf..8d44465 100644
--- a/src/anonymous.c
+++ b/src/anonymous.c
@@ -30,7 +30,7 @@
short int is_anonymous_enabled (void)
{
- return (config.anonymous_map != NULL) ? 1 : 0;
+ return (config->anonymous_map != NULL) ? 1 : 0;
}
/*
@@ -40,9 +40,9 @@ short int is_anonymous_enabled (void)
int anonymous_search (const char *s)
{
assert (s != NULL);
- assert (config.anonymous_map != NULL);
+ assert (config->anonymous_map != NULL);
- return hashmap_search (config.anonymous_map, s);
+ return hashmap_search (config->anonymous_map, s);
}
/*
@@ -57,17 +57,17 @@ int anonymous_insert (const char *s)
assert (s != NULL);
- if (!config.anonymous_map) {
- config.anonymous_map = hashmap_create (32);
- if (!config.anonymous_map)
+ if (!config->anonymous_map) {
+ config->anonymous_map = hashmap_create (32);
+ if (!config->anonymous_map)
return -1;
}
- if (hashmap_search (config.anonymous_map, s) > 0) {
+ if (hashmap_search (config->anonymous_map, s) > 0) {
/* The key was already found, so return a positive number. */
return 0;
}
/* Insert the new key */
- return hashmap_insert (config.anonymous_map, s, &data, sizeof (data));
+ return hashmap_insert (config->anonymous_map, s, &data, sizeof (data));
}