mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 06:56:14 +01:00
girparser: Simplify the ownership of context modules and parsed ones
There's no need to copy the list of modules and free it again, we can just handle this by moving the modules to the parser promptly.
This commit is contained in:
parent
23d3a5e859
commit
2e2e606208
@ -3775,6 +3775,7 @@ gi_ir_parser_parse_string (GIIrParser *parser,
|
||||
{
|
||||
ParseContext ctx = { 0 };
|
||||
GMarkupParseContext *context;
|
||||
GIIrModule *module = NULL;
|
||||
|
||||
ctx.parser = parser;
|
||||
ctx.state = STATE_START;
|
||||
@ -3806,12 +3807,15 @@ gi_ir_parser_parse_string (GIIrParser *parser,
|
||||
if (!g_markup_parse_context_end_parse (context, error))
|
||||
goto out;
|
||||
|
||||
parser->parsed_modules = g_list_concat (g_list_copy (ctx.modules),
|
||||
if (ctx.modules)
|
||||
module = ctx.modules->data;
|
||||
|
||||
parser->parsed_modules = g_list_concat (g_steal_pointer (&ctx.modules),
|
||||
parser->parsed_modules);
|
||||
|
||||
out:
|
||||
|
||||
if (ctx.modules == NULL)
|
||||
if (module == NULL)
|
||||
{
|
||||
/* An error occurred before we created a module, so we haven't
|
||||
* transferred ownership of these hash tables to the module.
|
||||
@ -3827,13 +3831,8 @@ gi_ir_parser_parse_string (GIIrParser *parser,
|
||||
g_clear_list (&ctx.dependencies, g_free);
|
||||
g_markup_parse_context_free (context);
|
||||
|
||||
if (ctx.modules)
|
||||
{
|
||||
GIIrModule *module = ctx.modules->data;
|
||||
|
||||
g_clear_list (&ctx.modules, NULL);
|
||||
return module;
|
||||
}
|
||||
if (module)
|
||||
return module;
|
||||
|
||||
if (error && *error == NULL)
|
||||
g_set_error (error,
|
||||
|
Loading…
Reference in New Issue
Block a user