]> git.ipfire.org Git - pakfire.git/commitdiff
repo: Keep a reference to the context
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 16 Oct 2023 15:32:40 +0000 (15:32 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 16 Oct 2023 15:32:40 +0000 (15:32 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/repo.c

index 7c7442626a3894a9a7b03e5145b5ae2dcf18357f..fc488c642f6b5a8f2d4ab19a8b72493bbc151d3a 100644 (file)
@@ -35,6 +35,7 @@
 #include <pakfire/compress.h>
 #include <pakfire/config.h>
 #include <pakfire/constants.h>
+#include <pakfire/ctx.h>
 #include <pakfire/downloader.h>
 #include <pakfire/file.h>
 #include <pakfire/filelist.h>
@@ -81,6 +82,7 @@ struct pakfire_repo_appdata {
 };
 
 struct pakfire_repo {
+       struct pakfire_ctx* ctx;
        struct pakfire* pakfire;
        int nrefs;
 
@@ -743,7 +745,10 @@ static void pakfire_repo_free(struct pakfire_repo* repo, const int free_repo) {
 
        if (repo->mirrorlist)
                pakfire_mirrorlist_unref(repo->mirrorlist);
-       pakfire_unref(repo->pakfire);
+       if (repo->pakfire)
+               pakfire_unref(repo->pakfire);
+       if (repo->ctx)
+               pakfire_ctx_unref(repo->ctx);
        free(repo);
 }
 
@@ -792,6 +797,9 @@ PAKFIRE_EXPORT int pakfire_repo_create(struct pakfire_repo** repo,
        if (!rep)
                return 1;
 
+       // Store a reference to the context
+       rep->ctx = pakfire_ctx(pakfire);
+
        rep->pakfire = pakfire_ref(pakfire);
        rep->nrefs = 1;