tree-wide: replace reallocarray() with GREEDY_REALLOC()

This commit is contained in:
Yu Watanabe
2024-10-08 19:56:09 +09:00
parent 5f9f38b8df
commit 223a67e572
18 changed files with 81 additions and 177 deletions
+2 -5
View File
@@ -201,7 +201,6 @@ int config_parse_dns(
for (const char *p = rvalue;;) {
_cleanup_(in_addr_full_freep) struct in_addr_full *dns = NULL;
_cleanup_free_ char *w = NULL;
struct in_addr_full **m;
r = extract_first_word(&p, &w, NULL, 0);
if (r == -ENOMEM)
@@ -224,12 +223,10 @@ int config_parse_dns(
if (IN_SET(dns->port, 53, 853))
dns->port = 0;
m = reallocarray(n->dns, n->n_dns + 1, sizeof(struct in_addr_full*));
if (!m)
if (!GREEDY_REALLOC(n->dns, n->n_dns + 1))
return log_oom();
m[n->n_dns++] = TAKE_PTR(dns);
n->dns = m;
n->dns[n->n_dns++] = TAKE_PTR(dns);
}
}
+2 -5
View File
@@ -1331,13 +1331,10 @@ int config_parse_radv_dns(
}
}
struct in6_addr *m;
m = reallocarray(n->router_dns, n->n_router_dns + 1, sizeof(struct in6_addr));
if (!m)
if (!GREEDY_REALLOC(n->router_dns, n->n_router_dns + 1))
return log_oom();
m[n->n_router_dns++] = a.in6;
n->router_dns = m;
n->router_dns[n->n_router_dns++] = a.in6;
}
}