]> git.ipfire.org Git - pakfire.git/commitdiff
xfer: Only copy the URL once
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 12 Oct 2024 19:16:23 +0000 (19:16 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 12 Oct 2024 19:16:23 +0000 (19:16 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/include/pakfire/string.h
src/libpakfire/xfer.c

index b1aa2ae25f5f4018d770447678b97e4dc3b9e474..6b21dc3f7ede4a2eda8d056f5b52853c23b1c9e2 100644 (file)
@@ -34,6 +34,9 @@
        __pakfire_string_format(s, sizeof(s), format, __VA_ARGS__)
 int __pakfire_string_format(char* s, const size_t length,
        const char* format, ...) __attribute__((format(printf, 3, 4)));
+
+#define pakfire_string_vformat(s, format, args) \
+       __pakfire_string_vformat(s, sizeof(s), format, args)
 int __pakfire_string_vformat(char* s, const size_t length,
        const char* format, va_list args) __attribute__((format(printf, 3, 0)));
 
index 4f4b0c93229d55fda1d13308eac28d3f25e1b162..beb12f307d890579b42977db3ef4ffecdaf6746b 100644 (file)
@@ -343,7 +343,6 @@ ERROR:
 int pakfire_xfer_create(struct pakfire_xfer** xfer,
                struct pakfire_ctx* ctx, const char* url, va_list args) {
        struct pakfire_xfer* x = NULL;
-       char buffer[PATH_MAX];
        int r;
 
        // Fail if the context is flagged as offline
@@ -352,11 +351,6 @@ int pakfire_xfer_create(struct pakfire_xfer** xfer,
                return -EPERM;
        }
 
-       // Format the URL
-       r = __pakfire_string_vformat(buffer, sizeof(buffer), url, args);
-       if (r < 0)
-               return r;
-
        // Allocate a new xfer
        x = calloc(1, sizeof(*x));
        if (!x)
@@ -369,7 +363,7 @@ int pakfire_xfer_create(struct pakfire_xfer** xfer,
        x->nrefs = 1;
 
        // Store the URL
-       r = pakfire_string_set(x->url, buffer);
+       r = pakfire_string_vformat(x->url, url, args);
        if (r)
                goto ERROR;