summaryrefslogtreecommitdiff
path: root/src/basic/strv.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-02-27 19:09:22 +0100
committerLennart Poettering <lennart@poettering.net>2018-03-02 12:39:07 +0100
commit62d74c78b59f95a76778d9fa8dbe3b098afa2aad (patch)
tree138ea4e336b01254a6766e547fdc10c3728255ef /src/basic/strv.c
parent3209c8e6502c095bb7a88a3e915f06dd56228ed4 (diff)
downloadsystemd-62d74c78b59f95a76778d9fa8dbe3b098afa2aad.tar.gz
coccinelle: add reallocarray() coccinelle script
Let's systematically make use of reallocarray() whereever we invoke realloc() with a product of two values.
Diffstat (limited to 'src/basic/strv.c')
-rw-r--r--src/basic/strv.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/basic/strv.c b/src/basic/strv.c
index 020fa269d7..e80ff4a62c 100644
--- a/src/basic/strv.c
+++ b/src/basic/strv.c
@@ -214,7 +214,7 @@ int strv_extend_strv(char ***a, char **b, bool filter_duplicates) {
p = strv_length(*a);
q = strv_length(b);
- t = realloc(*a, sizeof(char*) * (p + q + 1));
+ t = reallocarray(*a, p + q + 1, sizeof(char *));
if (!t)
return -ENOMEM;
@@ -861,7 +861,7 @@ int strv_extend_n(char ***l, const char *value, size_t n) {
k = strv_length(*l);
- nl = realloc(*l, sizeof(char*) * (k + n + 1));
+ nl = reallocarray(*l, k + n + 1, sizeof(char *));
if (!nl)
return -ENOMEM;