#include <errno.h>
#include <stdlib.h>
-// Enable legacy logging
-#define PAKFIRE_LEGACY_LOGGING
-
#include <pakfire/constants.h>
#include <pakfire/ctx.h>
#include <pakfire/dependencies.h>
int pakfire_problem_create(struct pakfire_problem** problem,
struct pakfire* pakfire, struct pakfire_transaction* transaction, Id id) {
- struct pakfire_problem* p = calloc(1, sizeof(*p));
+ struct pakfire_problem* p = NULL;
+
+ // Allocate some memory
+ p = calloc(1, sizeof(*p));
if (!p)
- return 1;
+ return -errno;
+ // Store a reference to the context
p->ctx = pakfire_ctx(pakfire);
+
+ // Store a reference to Pakfire
p->pakfire = pakfire_ref(pakfire);
+
+ // Initialize the reference counter
p->nrefs = 1;
+ // Store a reference to the transaction
p->transaction = pakfire_transaction_ref(transaction);
+
+ // Store the ID
p->id = id;
// Fetch a reference to the solver
p->solver = pakfire_transaction_get_solver(transaction);
+ // Return the pointer
*problem = p;
- return 0;
-}
-
-PAKFIRE_EXPORT struct pakfire_problem* pakfire_problem_ref(struct pakfire_problem* problem) {
- problem->nrefs++;
- return problem;
+ return 0;
}
static void pakfire_problem_free(struct pakfire_problem* problem) {
free(problem);
}
+PAKFIRE_EXPORT struct pakfire_problem* pakfire_problem_ref(struct pakfire_problem* problem) {
+ problem->nrefs++;
+
+ return problem;
+}
+
PAKFIRE_EXPORT struct pakfire_problem* pakfire_problem_unref(struct pakfire_problem* problem) {
if (--problem->nrefs > 0)
return problem;