diff options
author | Lennart Poettering <lennart@poettering.net> | 2020-01-21 10:07:34 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2020-01-21 10:07:34 +0100 |
commit | 2e5180d38b33710506ab76dcf93f802864b9ec0f (patch) | |
tree | d246a21a2b8b2b7119843b732b880973722844ca /src/libsystemd/sd-hwdb | |
parent | cdc6804b6046282a42117678751c126a022cd24a (diff) | |
download | systemd-2e5180d38b33710506ab76dcf93f802864b9ec0f.tar.gz |
strv: get rid of strv_clear()
Let's remove a function of questionnable utility.
strv_clear() frees the items of a string array, but not the array
itself. i.e. it half-drestructs a string array and makes it empty. This
is not too useful an operation since we almost never need to just do
that, we also want to free the whole thing. In fact, strv_clear() is
only used in one of our .c file, and there it appears like unnecessary
optimization, given that for each array with n elements it leaves the
number of free()s we need to at O(n) which is not really an optimization
at all (it goes from n+1 to n, that's all).
Prompted by the discussions on #14605
Diffstat (limited to 'src/libsystemd/sd-hwdb')
-rw-r--r-- | src/libsystemd/sd-hwdb/hwdb-util.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libsystemd/sd-hwdb/hwdb-util.c b/src/libsystemd/sd-hwdb/hwdb-util.c index c83575c7c8..1a2da9c79b 100644 --- a/src/libsystemd/sd-hwdb/hwdb-util.c +++ b/src/libsystemd/sd-hwdb/hwdb-util.c @@ -543,7 +543,7 @@ static int import_file(struct trie *trie, const char *filename, uint16_t file_pr "Property expected, ignoring record with no properties"); r = -EINVAL; state = HW_NONE; - strv_clear(match_list); + match_list = strv_free(match_list); break; } @@ -571,7 +571,7 @@ static int import_file(struct trie *trie, const char *filename, uint16_t file_pr if (len == 0) { /* end of record */ state = HW_NONE; - strv_clear(match_list); + match_list = strv_free(match_list); break; } @@ -580,7 +580,7 @@ static int import_file(struct trie *trie, const char *filename, uint16_t file_pr "Property or empty line expected, got \"%s\", ignoring record", line); r = -EINVAL; state = HW_NONE; - strv_clear(match_list); + match_list = strv_free(match_list); break; } |