Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Allow AppStream to parse recommendations #45

Closed
wants to merge 8 commits into from
Copy path View file
@@ -442,6 +442,50 @@ as_xmldata_process_screenshots_tag (AsXMLData *xdt, xmlNode* node, AsComponent*
}
}

/**
* as_xmldata_process_suggests_tag:
*/
static void
as_xmldata_process_suggests_tag (AsXMLData *xdt, xmlNode* node, AsComponent* cpt)
{
xmlNode *iter;
AsSuggested *suggested = NULL;
AsSuggestedKind suggested_kind;
gchar *node_name;
gchar *type_str;
gchar *content;

g_return_if_fail (xdt != NULL);
g_return_if_fail (cpt != NULL);

suggested = as_suggested_new ();

This comment has been minimized.

Copy link
@ximion

ximion Aug 9, 2016

Owner

You are leaking memory here.

type_str = (gchar*) xmlGetProp (node, (xmlChar*) "type");

This comment has been minimized.

Copy link
@ximion

ximion Aug 9, 2016

Owner

...and here (needs to be free'd)


if (type_str != NULL) {
suggested_kind = as_suggested_kind_from_string (type_str);
as_suggested_set_kind (suggested, suggested_kind);
}

for (iter = node->children; iter != NULL; iter = iter->next) {
/* discard spaces */
if (iter->type != XML_ELEMENT_NODE)
continue;

node_name = (gchar*) iter->name;

if (g_strcmp0 (node_name, "id") == 0) {
content = as_xmldata_get_node_value (xdt, iter);

This comment has been minimized.

Copy link
@ximion

ximion Aug 9, 2016

Owner

As well as here (actually, this is probably the biggest leak, since this needs to be freed on each iteration)


if (content != NULL)
as_suggested_add_component_id (suggested, content);
}

if (as_suggested_is_valid (suggested))
as_component_add_suggestion (cpt, suggested);

This comment has been minimized.

Copy link
@ximion

ximion Aug 9, 2016

Owner

You are adding the AsSuggested again and again here, once per ID...


}
}

/**
* as_xmldata_upstream_description_to_cpt:
*
@@ -940,6 +984,8 @@ as_xmldata_parse_component_node (AsXMLData *xdt, xmlNode* node, AsComponent *cpt
as_xmldata_process_provides (xdt, iter, cpt);
} else if (g_strcmp0 (node_name, "screenshots") == 0) {
as_xmldata_process_screenshots_tag (xdt, iter, cpt);
} else if (g_strcmp0 (node_name, "suggests") == 0) {
as_xmldata_process_suggests_tag (xdt, iter, cpt);
} else if (g_strcmp0 (node_name, "project_license") == 0) {
if (content != NULL)
as_component_set_project_license (cpt, content);
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.