static int pakfire_repo_xfer_create(
struct pakfire_xfer** xfer, struct pakfire_repo* repo, const char* url, ...) {
struct pakfire_mirrorlist* mirrorlist = NULL;
+ struct pakfire_xfer* x = NULL;
const char* baseurl = NULL;
va_list args;
int r;
va_start(args, url);
// Create a new transfer
- r = pakfire_xfer_create(xfer, repo->ctx, url, args);
+ r = pakfire_xfer_create(&x, repo->ctx, url, args);
if (r < 0)
goto ERROR;
// Set the baseurl
baseurl = pakfire_repo_get_expanded_baseurl(repo);
if (baseurl) {
- r = pakfire_xfer_set_baseurl(*xfer, baseurl);
+ r = pakfire_xfer_set_baseurl(x, baseurl);
if (r < 0)
goto ERROR;
}
// Set the mirrorlist
mirrorlist = pakfire_repo_get_mirrorlist(repo);
if (mirrorlist) {
- r = pakfire_xfer_set_mirrorlist(*xfer, mirrorlist);
+ r = pakfire_xfer_set_mirrorlist(x, mirrorlist);
if (r < 0)
goto ERROR;
}
+ // Success
+ *xfer = pakfire_xfer_ref(x);
+
ERROR:
if (mirrorlist)
pakfire_mirrorlist_unref(mirrorlist);
-
- // Destroy the xfer on error
- if (r) {
- if (*xfer)
- pakfire_xfer_unref(*xfer);
- }
+ if (x)
+ pakfire_xfer_unref(x);
va_end(args);
return r;