From: Michael Tremer Date: Fri, 20 Oct 2023 11:59:49 +0000 (+0000) Subject: db: Store a reference to the context X-Git-Tag: 0.9.30~1418 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=229beb2099302c5299baffb9a0bfdf2a7ffec4e0;p=pakfire.git db: Store a reference to the context Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/db.c b/src/libpakfire/db.c index 97c9da440..8fd354e6b 100644 --- a/src/libpakfire/db.c +++ b/src/libpakfire/db.c @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -46,6 +47,7 @@ #define SCHEMA_MIN_SUP 7 struct pakfire_db { + struct pakfire_ctx* ctx; struct pakfire* pakfire; int nrefs; @@ -373,8 +375,10 @@ static void pakfire_db_free(struct pakfire_db* db) { } } - pakfire_unref(db->pakfire); - + if (db->pakfire) + pakfire_unref(db->pakfire); + if (db->ctx) + pakfire_ctx_unref(db->ctx); free(db); } @@ -680,6 +684,9 @@ int pakfire_db_open(struct pakfire_db** db, struct pakfire* pakfire, int flags) if (!o) return -ENOMEM; + // Store a reference to the context + o->ctx = pakfire_ctx(pakfire); + o->pakfire = pakfire_ref(pakfire); o->nrefs = 1;