]> git.ipfire.org Git - pakfire.git/commitdiff
solution: Add a reference to the context and remove root
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 29 Jun 2025 12:38:57 +0000 (12:38 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 29 Jun 2025 12:38:57 +0000 (12:38 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/problem.c
src/pakfire/solution.c
src/pakfire/solution.h

index 9b4d3a54ff75f1f38e9ffd75ca7aaaea5c4664cf..45490f154e389618dc4cc87a45c6beafd9f28cdf 100644 (file)
@@ -290,7 +290,7 @@ pakfire_solution** pakfire_problem_get_solutions(
                        break;
 
                // Create a new solution
-               r = pakfire_solution_create(&solution, problem->root, problem, id);
+               r = pakfire_solution_create(&solution, problem->ctx, problem, id);
                if (r)
                        goto ERROR;
 
index f4469dad21ccc73c5177ff3a05844aed5a950185..dfa2da8b5ffb4c8784d6dbf5784a2878ec426155 100644 (file)
@@ -24,6 +24,7 @@
 #include <solv/policy.h>
 
 #include <pakfire/constants.h>
+#include <pakfire/ctx.h>
 #include <pakfire/i18n.h>
 #include <pakfire/logging.h>
 #include <pakfire/root.h>
@@ -34,7 +35,7 @@
 #include <pakfire/util.h>
 
 struct pakfire_solution {
-       pakfire_root* root;
+       pakfire_ctx* ctx;
        int nrefs;
 
        pakfire_problem* problem;
@@ -43,13 +44,13 @@ struct pakfire_solution {
 };
 
 int pakfire_solution_create(pakfire_solution** solution,
-               pakfire_root* root, pakfire_problem* problem, Id id) {
+               pakfire_ctx* ctx, pakfire_problem* problem, Id id) {
        pakfire_solution* s = calloc(1, sizeof(*s));
        if (!s)
                return -errno;
 
-       // Store a reference to the root
-       s->root = pakfire_root_ref(root);
+       // Store a reference to the context
+       s->ctx = pakfire_ctx_ref(ctx);
 
        // Initialize the ref counter
        s->nrefs = 1;
@@ -75,9 +76,8 @@ static void pakfire_solution_free(pakfire_solution* solution) {
 
        if (solution->string)
                free(solution->string);
-
-       if (solution->root)
-               pakfire_root_unref(solution->root);
+       if (solution->ctx)
+               pakfire_ctx_unref(solution->ctx);
        free(solution);
 }
 
index 55d42aca8514d080fd56403f8ac61a536eba7ed9..0dcc2fa3c08529e1ad8e01907ce29ace8f71aa40 100644 (file)
 
 typedef struct pakfire_solution pakfire_solution;
 
-#include <pakfire/root.h>
+#include <pakfire/ctx.h>
 #include <pakfire/problem.h>
 
+int pakfire_solution_create(pakfire_solution** solution,
+       pakfire_ctx* ctx, pakfire_problem* problem, Id id);
+
 pakfire_solution* pakfire_solution_ref(pakfire_solution* solution);
 pakfire_solution* pakfire_solution_unref(pakfire_solution* solution);
 
 const char* pakfire_solution_to_string(pakfire_solution* solution);
 
-int pakfire_solution_create(pakfire_solution** solution, pakfire_root* root,
-       pakfire_problem* problem, Id id);
 pakfire_problem* pakfire_solution_get_problem(pakfire_solution* solution);
 Id pakfire_solution_get_id(pakfire_solution* solution);