From: Michael Tremer Date: Mon, 29 Jan 2024 17:42:33 +0000 (+0000) Subject: parser: Store a reference to the context X-Git-Tag: 0.9.30~1233 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7a2a317343bbdb964ed4b5afa210987871edf500;p=pakfire.git parser: Store a reference to the context Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/parser.c b/src/libpakfire/parser.c index 43fcf4442..263001b7d 100644 --- a/src/libpakfire/parser.c +++ b/src/libpakfire/parser.c @@ -33,6 +33,7 @@ // Enable legacy logging #define PAKFIRE_LEGACY_LOGGING +#include #include #include #include @@ -43,6 +44,7 @@ #include struct pakfire_parser { + struct pakfire_ctx* ctx; struct pakfire* pakfire; int nrefs; @@ -84,6 +86,7 @@ struct pakfire_parser* pakfire_parser_create(struct pakfire* pakfire, struct pakfire_parser* parent, const char* namespace, int flags) { struct pakfire_parser* parser = calloc(1, sizeof(*parser)); if (parser) { + parser->ctx = pakfire_ctx(pakfire); parser->pakfire = pakfire_ref(pakfire); parser->nrefs = 1; @@ -145,8 +148,10 @@ static void pakfire_parser_free(struct pakfire_parser* parser) { if (parser->parent) pakfire_parser_unref(parser->parent); - - pakfire_unref(parser->pakfire); + if (parser->pakfire) + pakfire_unref(parser->pakfire); + if (parser->ctx) + pakfire_ctx_unref(parser->ctx); free(parser); }