]> git.ipfire.org Git - pakfire.git/commitdiff
problem: Store a reference to the context
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 29 Jan 2024 17:45:13 +0000 (17:45 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 29 Jan 2024 17:45:13 +0000 (17:45 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/problem.c

index d76f0bcc6575c39b0ab3b883ec75bd4aaac16915..5d696dd06897218df36bac4b0a2299b86f916a51 100644 (file)
@@ -25,6 +25,7 @@
 #define PAKFIRE_LEGACY_LOGGING
 
 #include <pakfire/constants.h>
+#include <pakfire/ctx.h>
 #include <pakfire/dependencies.h>
 #include <pakfire/i18n.h>
 #include <pakfire/logging.h>
@@ -36,6 +37,7 @@
 #include <pakfire/util.h>
 
 struct pakfire_problem {
+       struct pakfire_ctx* ctx;
        struct pakfire* pakfire;
        int nrefs;
 
@@ -198,6 +200,7 @@ int pakfire_problem_create(struct pakfire_problem** problem,
        if (!p)
                return 1;
 
+       p->ctx = pakfire_ctx(pakfire);
        p->pakfire = pakfire_ref(pakfire);
        p->nrefs = 1;
 
@@ -222,7 +225,10 @@ static void pakfire_problem_free(struct pakfire_problem* problem) {
                pakfire_transaction_unref(problem->transaction);
        if (problem->string)
                free(problem->string);
-       pakfire_unref(problem->pakfire);
+       if (problem->pakfire)
+               pakfire_unref(problem->pakfire);
+       if (problem->ctx)
+               pakfire_ctx_unref(problem->ctx);
        free(problem);
 }