#include <pakfire/archive.h>
#include <pakfire/constants.h>
+#include <pakfire/ctx.h>
#include <pakfire/dependencies.h>
#include <pakfire/digest.h>
#include <pakfire/file.h>
#include <pakfire/util.h>
struct pakfire_package {
+ struct pakfire_ctx* ctx;
struct pakfire* pakfire;
int nrefs;
if (!pkg)
return 1;
+ // Store a reference to the context
+ pkg->ctx = pakfire_ctx(pakfire);
+
pkg->pakfire = pakfire_ref(pakfire);
pkg->nrefs = 1;
static void pakfire_package_free(struct pakfire_package* pkg) {
if (pkg->repo)
pakfire_repo_unref(pkg->repo);
-
- pakfire_unref(pkg->pakfire);
+ if (pkg->pakfire)
+ pakfire_unref(pkg->pakfire);
+ if (pkg->ctx)
+ pakfire_ctx_unref(pkg->ctx);
free(pkg);
}