From: Michael Tremer Date: Sun, 29 Jun 2025 12:38:57 +0000 (+0000) Subject: solution: Add a reference to the context and remove root X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=da6541a4a1c08b2f2779a59a3cdb5ab6173d4bd7;p=pakfire.git solution: Add a reference to the context and remove root Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/problem.c b/src/pakfire/problem.c index 9b4d3a54..45490f15 100644 --- a/src/pakfire/problem.c +++ b/src/pakfire/problem.c @@ -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; diff --git a/src/pakfire/solution.c b/src/pakfire/solution.c index f4469dad..dfa2da8b 100644 --- a/src/pakfire/solution.c +++ b/src/pakfire/solution.c @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -34,7 +35,7 @@ #include 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); } diff --git a/src/pakfire/solution.h b/src/pakfire/solution.h index 55d42aca..0dcc2fa3 100644 --- a/src/pakfire/solution.h +++ b/src/pakfire/solution.h @@ -26,16 +26,17 @@ typedef struct pakfire_solution pakfire_solution; -#include +#include #include +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);