summaryrefslogtreecommitdiff
path: root/src/libsystemd
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-11-29 15:17:19 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-11-30 15:51:08 -0500
commit1cd592b91679f3a04fe884d51dd2b9d65eb5f2f9 (patch)
tree753edadb0e6bdff4bcdcd495ba951e52fdaff7e6 /src/libsystemd
parentd8646d05724a658cc60fb03f105db8ead454eba3 (diff)
sd-hwdb: drop caching of search string
We have only two callers, and for neither this "optimization" is useful. So let's drop it an save some code and a malloc.
Diffstat (limited to 'src/libsystemd')
-rw-r--r--src/libsystemd/sd-hwdb/sd-hwdb.c24
1 files changed, 1 insertions, 23 deletions
diff --git a/src/libsystemd/sd-hwdb/sd-hwdb.c b/src/libsystemd/sd-hwdb/sd-hwdb.c
index a8c6376302..c155c70162 100644
--- a/src/libsystemd/sd-hwdb/sd-hwdb.c
+++ b/src/libsystemd/sd-hwdb/sd-hwdb.c
@@ -48,8 +48,6 @@ struct sd_hwdb {
const char *map;
};
- char *modalias;
-
OrderedHashmap *properties;
Iterator properties_iterator;
bool properties_modified;
@@ -393,7 +391,6 @@ _public_ sd_hwdb *sd_hwdb_unref(sd_hwdb *hwdb) {
if (hwdb->map)
munmap((void *)hwdb->map, hwdb->st.st_size);
safe_fclose(hwdb->f);
- free(hwdb->modalias);
ordered_hashmap_free(hwdb->properties);
free(hwdb);
}
@@ -427,32 +424,13 @@ bool hwdb_validate(sd_hwdb *hwdb) {
}
static int properties_prepare(sd_hwdb *hwdb, const char *modalias) {
- _cleanup_free_ char *mod = NULL;
- int r;
-
assert(hwdb);
assert(modalias);
- if (streq_ptr(modalias, hwdb->modalias))
- return 0;
-
- mod = strdup(modalias);
- if (!mod)
- return -ENOMEM;
-
ordered_hashmap_clear(hwdb->properties);
-
hwdb->properties_modified = true;
- r = trie_search_f(hwdb, modalias);
- if (r < 0)
- return r;
-
- free(hwdb->modalias);
- hwdb->modalias = mod;
- mod = NULL;
-
- return 0;
+ return trie_search_f(hwdb, modalias);
}
_public_ int sd_hwdb_get(sd_hwdb *hwdb, const char *modalias, const char *key, const char **_value) {