From: Michael Tremer Date: Fri, 2 Jul 2021 15:57:44 +0000 (+0000) Subject: solution: Change type from PakfireSolution to struct pakfire_solution X-Git-Tag: 0.9.28~1126 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bf647a4b484b6f6b6884c47d2ebddc5201dcd7ab;p=pakfire.git solution: Change type from PakfireSolution to struct pakfire_solution Signed-off-by: Michael Tremer --- diff --git a/src/_pakfire/problem.c b/src/_pakfire/problem.c index 23f4430f8..120569c1a 100644 --- a/src/_pakfire/problem.c +++ b/src/_pakfire/problem.c @@ -21,6 +21,7 @@ #include #include +#include #include "problem.h" #include "solution.h" @@ -83,7 +84,7 @@ static PyObject* Problem_string(ProblemObject* self) { static PyObject* Problem_get_solutions(ProblemObject* self) { PyObject* list = PyList_New(0); - PakfireSolution solution = pakfire_problem_get_solutions(self->problem); + struct pakfire_solution* solution = pakfire_problem_get_solutions(self->problem); while (solution) { PyObject* s = new_solution(solution); PyList_Append(list, s); diff --git a/src/_pakfire/solution.c b/src/_pakfire/solution.c index af7ed86aa..b0315cd7e 100644 --- a/src/_pakfire/solution.c +++ b/src/_pakfire/solution.c @@ -24,7 +24,7 @@ #include "solution.h" -static SolutionObject* Solution_new_core(PyTypeObject* type, PakfireSolution solution) { +static SolutionObject* Solution_new_core(PyTypeObject* type, struct pakfire_solution* solution) { SolutionObject* self = (SolutionObject *)type->tp_alloc(type, 0); if (self) { self->solution = solution; @@ -33,7 +33,7 @@ static SolutionObject* Solution_new_core(PyTypeObject* type, PakfireSolution sol return self; } -PyObject* new_solution(PakfireSolution solution) { +PyObject* new_solution(struct pakfire_solution* solution) { SolutionObject* s = Solution_new_core(&SolutionType, solution); return (PyObject*)s; diff --git a/src/_pakfire/solution.h b/src/_pakfire/solution.h index 44d6fcda9..cd5bb3e05 100644 --- a/src/_pakfire/solution.h +++ b/src/_pakfire/solution.h @@ -27,11 +27,11 @@ typedef struct { PyObject_HEAD - PakfireSolution solution; + struct pakfire_solution* solution; } SolutionObject; extern PyTypeObject SolutionType; -PyObject* new_solution(PakfireSolution solution); +PyObject* new_solution(struct pakfire_solution* solution); #endif /* PYTHON_PAKFIRE_SOLUTION_H */ diff --git a/src/libpakfire/include/pakfire/problem.h b/src/libpakfire/include/pakfire/problem.h index f4ffd5ad1..c391918ee 100644 --- a/src/libpakfire/include/pakfire/problem.h +++ b/src/libpakfire/include/pakfire/problem.h @@ -21,17 +21,18 @@ #ifndef PAKFIRE_PROBLEM_H #define PAKFIRE_PROBLEM_H -#include - struct pakfire_problem; +#include +#include + struct pakfire_problem* pakfire_problem_ref(struct pakfire_problem* problem); struct pakfire_problem* pakfire_problem_unref(struct pakfire_problem* problem); const char* pakfire_problem_to_string(struct pakfire_problem* problem); struct pakfire_request* pakfire_problem_get_request(struct pakfire_problem* problem); -PakfireSolution pakfire_problem_get_solutions(struct pakfire_problem* problem); +struct pakfire_solution* pakfire_problem_get_solutions(struct pakfire_problem* problem); #ifdef PAKFIRE_PRIVATE diff --git a/src/libpakfire/include/pakfire/solution.h b/src/libpakfire/include/pakfire/solution.h index 1c833a513..4e36f73ab 100644 --- a/src/libpakfire/include/pakfire/solution.h +++ b/src/libpakfire/include/pakfire/solution.h @@ -23,15 +23,17 @@ #include +struct pakfire_solution; + #include -PakfireSolution pakfire_solution_create(struct pakfire_problem* problem, Id id); -PakfireSolution pakfire_solution_ref(PakfireSolution solution); -PakfireSolution pakfire_solution_unref(PakfireSolution solution); +struct pakfire_solution* pakfire_solution_create(struct pakfire_problem* problem, Id id); +struct pakfire_solution* pakfire_solution_ref(struct pakfire_solution* solution); +struct pakfire_solution* pakfire_solution_unref(struct pakfire_solution* solution); -PakfireSolution pakfire_solution_next(PakfireSolution solution); -void pakfire_solution_append(PakfireSolution solution, PakfireSolution new_solution); +struct pakfire_solution* pakfire_solution_next(struct pakfire_solution* solution); +void pakfire_solution_append(struct pakfire_solution* solution, struct pakfire_solution* new_solution); -char* pakfire_solution_to_string(PakfireSolution solution); +char* pakfire_solution_to_string(struct pakfire_solution* solution); #endif /* PAKFIRE_SOLUTION_H */ diff --git a/src/libpakfire/include/pakfire/types.h b/src/libpakfire/include/pakfire/types.h index 28b07102e..a450143b9 100644 --- a/src/libpakfire/include/pakfire/types.h +++ b/src/libpakfire/include/pakfire/types.h @@ -26,6 +26,5 @@ typedef struct _PakfireArchive* PakfireArchive; typedef struct _PakfireArchiveSignature* PakfireArchiveSignature; typedef struct _PakfireFilelist* PakfireFilelist; typedef struct _PakfireKey* PakfireKey; -typedef struct _PakfireSolution* PakfireSolution; #endif /* PAKFIRE_TYPES_H */ diff --git a/src/libpakfire/problem.c b/src/libpakfire/problem.c index 841408c61..2e8ec982f 100644 --- a/src/libpakfire/problem.c +++ b/src/libpakfire/problem.c @@ -262,13 +262,13 @@ PAKFIRE_EXPORT struct pakfire_request* pakfire_problem_get_request(struct pakfir return pakfire_request_ref(problem->request); } -PAKFIRE_EXPORT PakfireSolution pakfire_problem_get_solutions(struct pakfire_problem* problem) { - PakfireSolution ret = NULL; +PAKFIRE_EXPORT struct pakfire_solution* pakfire_problem_get_solutions(struct pakfire_problem* problem) { + struct pakfire_solution* ret = NULL; Solver* solver = pakfire_request_get_solver(problem->request); Id solution = 0; while ((solution = solver_next_solution(solver, problem->id, solution)) != 0) { - PakfireSolution s = pakfire_solution_create(problem, solution); + struct pakfire_solution* s = pakfire_solution_create(problem, solution); if (ret) pakfire_solution_append(ret, s); diff --git a/src/libpakfire/solution.c b/src/libpakfire/solution.c index 5eead890b..2459b8287 100644 --- a/src/libpakfire/solution.c +++ b/src/libpakfire/solution.c @@ -31,17 +31,18 @@ #include #include -struct _PakfireSolution { +struct pakfire_solution { Pakfire pakfire; + int nrefs; + struct pakfire_problem* problem; Id id; char** elements; - PakfireSolution next; - int nrefs; + struct pakfire_solution* next; }; -static void import_elements(PakfireSolution solution) { +static void import_elements(struct pakfire_solution* solution) { struct pakfire_request* request = pakfire_problem_get_request(solution->problem); Solver* solver = pakfire_request_get_solver(request); @@ -119,10 +120,10 @@ static void import_elements(PakfireSolution solution) { pakfire_request_unref(request); } -PAKFIRE_EXPORT PakfireSolution pakfire_solution_create(struct pakfire_problem* problem, Id id) { +PAKFIRE_EXPORT struct pakfire_solution* pakfire_solution_create(struct pakfire_problem* problem, Id id) { Pakfire pakfire = pakfire_problem_get_pakfire(problem); - PakfireSolution solution = calloc(1, sizeof(*solution)); + struct pakfire_solution* solution = calloc(1, sizeof(*solution)); if (solution) { DEBUG(pakfire, "Allocated Solution at %p\n", solution); solution->pakfire = pakfire_ref(pakfire); @@ -140,13 +141,13 @@ PAKFIRE_EXPORT PakfireSolution pakfire_solution_create(struct pakfire_problem* p return solution; } -PAKFIRE_EXPORT PakfireSolution pakfire_solution_ref(PakfireSolution solution) { +PAKFIRE_EXPORT struct pakfire_solution* pakfire_solution_ref(struct pakfire_solution* solution) { solution->nrefs++; return solution; } -static void pakfire_solution_free(PakfireSolution solution) { +static void pakfire_solution_free(struct pakfire_solution* solution) { DEBUG(solution->pakfire, "Releasing Solution at %p\n", solution); pakfire_unref(solution->pakfire); @@ -162,7 +163,7 @@ static void pakfire_solution_free(PakfireSolution solution) { free(solution); } -PAKFIRE_EXPORT PakfireSolution pakfire_solution_unref(PakfireSolution solution) { +PAKFIRE_EXPORT struct pakfire_solution* pakfire_solution_unref(struct pakfire_solution* solution) { if (!solution) return NULL; @@ -173,12 +174,12 @@ PAKFIRE_EXPORT PakfireSolution pakfire_solution_unref(PakfireSolution solution) return NULL; } -PAKFIRE_EXPORT PakfireSolution pakfire_solution_next(PakfireSolution solution) { +PAKFIRE_EXPORT struct pakfire_solution* pakfire_solution_next(struct pakfire_solution* solution) { return solution->next; } -PAKFIRE_EXPORT void pakfire_solution_append(PakfireSolution solution, PakfireSolution new_solution) { - PakfireSolution next; +PAKFIRE_EXPORT void pakfire_solution_append(struct pakfire_solution* solution, struct pakfire_solution* new_solution) { + struct pakfire_solution* next; // Go to last problem in list while ((next = pakfire_solution_next(solution)) != NULL) { @@ -188,7 +189,7 @@ PAKFIRE_EXPORT void pakfire_solution_append(PakfireSolution solution, PakfireSol solution->next = pakfire_solution_ref(new_solution); } -static size_t count_elements_length(PakfireSolution solution) { +static size_t count_elements_length(struct pakfire_solution* solution) { size_t length = 0; char** elements = solution->elements; @@ -199,7 +200,7 @@ static size_t count_elements_length(PakfireSolution solution) { return length; } -PAKFIRE_EXPORT char* pakfire_solution_to_string(PakfireSolution solution) { +PAKFIRE_EXPORT char* pakfire_solution_to_string(struct pakfire_solution* solution) { // Determine length of output string size_t length = count_elements_length(solution);