Merge pull request #8336 from poettering/coccinelle-reallocarray

reallocarray() coccinellization
This commit is contained in:
Lennart Poettering
2018-03-02 15:40:52 +01:00
committed by GitHub
19 changed files with 79 additions and 40 deletions
+1 -1
View File
@@ -721,7 +721,7 @@ char **replace_env_argv(char **argv, char **env) {
q = strv_length(m);
l = l + q - 1;
w = realloc(ret, sizeof(char*) * (l+1));
w = reallocarray(ret, l + 1, sizeof(char *));
if (!w) {
ret[k] = NULL;
strv_free(ret);
+1 -1
View File
@@ -173,7 +173,7 @@ int prioq_put(Prioq *q, void *data, unsigned *idx) {
struct prioq_item *j;
n = MAX((q->n_items+1) * 2, 16u);
j = realloc(q->items, sizeof(struct prioq_item) * n);
j = reallocarray(q->items, n, sizeof(struct prioq_item));
if (!j)
return -ENOMEM;
+1 -1
View File
@@ -190,7 +190,7 @@ ssize_t strbuf_add_string(struct strbuf *str, const char *s, size_t len) {
node_child->value_len = len;
/* extend array, add new entry, sort for bisection */
child = realloc(node->children, (node->children_count + 1) * sizeof(struct strbuf_child_entry));
child = reallocarray(node->children, node->children_count + 1, sizeof(struct strbuf_child_entry));
if (!child) {
free(node_child);
return -ENOMEM;
+2 -2
View File
@@ -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;