core/namespace: use GREEDY_REALLOC at one more place
authorMike Yuan <me@yhndnzj.com>
Wed, 4 Sep 2024 13:21:25 +0000 (15:21 +0200)
committerMike Yuan <me@yhndnzj.com>
Wed, 4 Sep 2024 19:44:24 +0000 (21:44 +0200)
src/core/namespace.c

index 323ff4c2794564ddabcffc22c8b9236cb09ccd0a..940052b04541aa47b8268eef76e01a3a33720854 100644 (file)
@@ -2777,7 +2777,6 @@ void bind_mount_free_many(BindMount *b, size_t n) {
 
 int bind_mount_add(BindMount **b, size_t *n, const BindMount *item) {
         _cleanup_free_ char *s = NULL, *d = NULL;
-        BindMount *c;
 
         assert(b);
         assert(n);
@@ -2791,13 +2790,10 @@ int bind_mount_add(BindMount **b, size_t *n, const BindMount *item) {
         if (!d)
                 return -ENOMEM;
 
-        c = reallocarray(*b, *n + 1, sizeof(BindMount));
-        if (!c)
+        if (!GREEDY_REALLOC(*b, *n + 1))
                 return -ENOMEM;
 
-        *b = c;
-
-        c[(*n)++] = (BindMount) {
+        (*b)[(*n)++] = (BindMount) {
                 .source = TAKE_PTR(s),
                 .destination = TAKE_PTR(d),
                 .read_only = item->read_only,