]> sourceware.org Git - lvm2.git/commitdiff
cleanup: previous patch with libdm config node buffer size
authorPeter Rajnoha <prajnoha@redhat.com>
Fri, 4 Mar 2016 14:19:09 +0000 (15:19 +0100)
committerPeter Rajnoha <prajnoha@redhat.com>
Fri, 4 Mar 2016 14:19:09 +0000 (15:19 +0100)
libdm/libdm-config.c

index a7f409635780219ce59b6ffefe3e549581fba1d2..5fa06a13197b74d122895ade977202470a9575e8 100644 (file)
@@ -222,7 +222,7 @@ __attribute__ ((format(printf, 2, 3)))
 static int _line_append(struct config_output *out, const char *fmt, ...)
 {
        char buf[4096];
-       char *final_buf;
+       char *dyn_buf = NULL;
        va_list ap;
        int n;
 
@@ -246,21 +246,23 @@ static int _line_append(struct config_output *out, const char *fmt, ...)
                 * so try dynamically allocated buffer now...
                 */
                va_start(ap, fmt);
-               n = dm_vasprintf(&final_buf, fmt, ap);
+               n = dm_vasprintf(&dyn_buf, fmt, ap);
                va_end(ap);
 
                if (n < 0) {
                        log_error("dm_vasprintf failed for config line");
                        return 0;
                }
-       } else
-               final_buf = buf;
+       }
 
-       if (!dm_pool_grow_object(out->mem, final_buf, strlen(final_buf))) {
+       if (!dm_pool_grow_object(out->mem, dyn_buf ? : buf, 0)) {
                log_error("dm_pool_grow_object failed for config line");
+               dm_free(dyn_buf);
                return 0;
        }
 
+       dm_free(dyn_buf);
+
        return 1;
 }
 
This page took 0.039971 seconds and 5 git commands to generate.