summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2019-03-27 21:04:05 -0400
committerTavian Barnes <tavianator@tavianator.com>2019-03-27 21:04:05 -0400
commitce5be644a16b3e4e7fdba0e0e4537daf3da70676 (patch)
treef198dbe1fc6d034f5ffcb6189af9fca2b7019554
parent4216dbac10887476feef287854e9e4037f2d1a59 (diff)
downloadbfs-ce5be644a16b3e4e7fdba0e0e4537daf3da70676.tar.xz
trie: Store void* values rather than const void*
Fewer casts needed this way.
-rw-r--r--color.c2
-rw-r--r--mtab.c2
-rw-r--r--parse.c4
-rw-r--r--trie.h2
4 files changed, 5 insertions, 5 deletions
diff --git a/color.c b/color.c
index e7c2958..29a87e1 100644
--- a/color.c
+++ b/color.c
@@ -188,7 +188,7 @@ static int set_ext_color(struct colors *colors, const char *key, const char *val
struct trie_leaf *leaf = trie_insert_str(&colors->ext_colors, xfrm);
free(xfrm);
if (leaf) {
- leaf->value = value;
+ leaf->value = (char *)value;
return 0;
} else {
return -1;
diff --git a/mtab.c b/mtab.c
index e2b89c9..50de0c7 100644
--- a/mtab.c
+++ b/mtab.c
@@ -219,7 +219,7 @@ void free_bfs_mtab(struct bfs_mtab *mtab) {
struct trie_leaf *leaf;
while ((leaf = trie_first_leaf(&mtab->types))) {
- free((char *)leaf->value);
+ free(leaf->value);
trie_remove_mem(&mtab->types, leaf->key, leaf->length);
}
trie_destroy(&mtab->types);
diff --git a/parse.c b/parse.c
index e6716eb..f60a963 100644
--- a/parse.c
+++ b/parse.c
@@ -264,7 +264,7 @@ int free_cmdline(struct cmdline *cmdline) {
struct trie_leaf *leaf;
while ((leaf = trie_first_leaf(&cmdline->open_files))) {
- struct open_file *ofile = (struct open_file *)leaf->value;
+ struct open_file *ofile = leaf->value;
if (cfclose(ofile->cfile) != 0) {
if (cerr) {
@@ -429,7 +429,7 @@ static int expr_open(struct parser_state *state, struct expr *expr, const char *
struct trie_leaf *leaf = trie_insert_mem(&cmdline->open_files, id, sizeof(id));
if (leaf->value) {
- struct open_file *ofile = (struct open_file *)leaf->value;
+ struct open_file *ofile = leaf->value;
expr->cfile = ofile->cfile;
ret = 0;
goto out_close;
diff --git a/trie.h b/trie.h
index 48f69cc..ae554e7 100644
--- a/trie.h
+++ b/trie.h
@@ -35,7 +35,7 @@ struct trie_leaf {
/**
* An arbitrary value associated with this leaf.
*/
- const void *value;
+ void *value;
/**
* The length of the key in bytes.