[libgrss/wip/GrssPerson] feed: Make all GrssPerson setters set a ref to it
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgrss/wip/GrssPerson] feed: Make all GrssPerson setters set a ref to it
- Date: Sat, 18 Jul 2015 12:02:16 +0000 (UTC)
commit ea87c2bfa95b9d9ddcf54b46cd8de78432478471
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat Jul 18 10:32:28 2015 +0200
feed: Make all GrssPerson setters set a ref to it
This makes memory management more consistent with the rest of the
API, esp. since GrrPerson is a refcounted type.
src/feed-atom-handler.c | 16 ++++++++++++----
src/feed-channel.c | 6 ++++--
src/feed-item.c | 14 ++++++++------
src/feed-pie-handler.c | 10 ++++++++--
src/feed-rss-handler.c | 13 ++++++++++---
src/ns-handler.c | 20 +++++++++++++++-----
6 files changed, 57 insertions(+), 22 deletions(-)
---
diff --git a/src/feed-atom-handler.c b/src/feed-atom-handler.c
index ca75e1d..7a20662 100644
--- a/src/feed-atom-handler.c
+++ b/src/feed-atom-handler.c
@@ -413,8 +413,10 @@ atom10_parse_entry_author (xmlNodePtr cur, GrssFeedItem *item, GrssFeedChannel *
GrssPerson *author;
author = atom10_parse_person_construct (cur);
- if (author)
+ if (author) {
grss_feed_item_set_author (item, author);
+ grss_person_unref (author);
+ }
}
static void
@@ -452,8 +454,10 @@ atom10_parse_entry_contributor (xmlNodePtr cur, GrssFeedItem *item, GrssFeedChan
GrssPerson *contributor;
contributor = atom10_parse_person_construct (cur);
- if (contributor)
+ if (contributor) {
grss_feed_item_add_contributor (item, contributor);
+ grss_person_unref (contributor);
+ }
}
static void
@@ -595,8 +599,10 @@ atom10_parse_feed_author (xmlNodePtr cur, GrssFeedChannel *feed)
GrssPerson *author;
author = atom10_parse_person_construct (cur);
- if (author)
+ if (author) {
grss_feed_channel_set_editor (feed, author);
+ grss_person_unref (author);
+ }
}
static void
@@ -623,8 +629,10 @@ atom10_parse_feed_contributor (xmlNodePtr cur, GrssFeedChannel *feed)
GrssPerson *contributor;
contributor = atom10_parse_person_construct (cur);
- if (contributor)
+ if (contributor) {
grss_feed_channel_add_contributor (feed, contributor);
+ grss_person_unref (contributor);
+ }
}
static void
diff --git a/src/feed-channel.c b/src/feed-channel.c
index 51441a0..00b6f9c 100644
--- a/src/feed-channel.c
+++ b/src/feed-channel.c
@@ -678,6 +678,8 @@ void
grss_feed_channel_set_editor (GrssFeedChannel *channel,
GrssPerson *editor)
{
+ if (editor)
+ grss_person_ref (editor);
if (channel->priv->editor != NULL)
grss_person_unref (channel->priv->editor);
channel->priv->editor = editor;
@@ -710,10 +712,10 @@ grss_feed_channel_add_contributor (GrssFeedChannel *channel,
{
if (channel->priv->contributors == NULL)
channel->priv->contributors = g_list_prepend (channel->priv->contributors,
- contributor);
+ grss_person_ref (contributor));
else
channel->priv->contributors = g_list_append (channel->priv->contributors,
- contributor);
+ grss_person_ref (contributor));
}
/**
diff --git a/src/feed-item.c b/src/feed-item.c
index c39bea7..2bf78c4 100644
--- a/src/feed-item.c
+++ b/src/feed-item.c
@@ -439,6 +439,8 @@ void
grss_feed_item_set_author (GrssFeedItem *item,
GrssPerson *author)
{
+ if (author)
+ grss_person_ref (author);
if (item->priv->author)
grss_person_unref (item->priv->author);
item->priv->author = author;
@@ -469,12 +471,12 @@ void
grss_feed_item_add_contributor (GrssFeedItem *item,
GrssPerson *contributor)
{
- if (item->priv->contributors == NULL)
- item->priv->contributors = g_list_prepend (item->priv->contributors,
- contributor);
- else
- item->priv->contributors = g_list_append (item->priv->contributors,
- contributor);
+ if (item->priv->contributors == NULL)
+ item->priv->contributors = g_list_prepend (item->priv->contributors,
+ grss_person_ref (contributor));
+ else
+ item->priv->contributors = g_list_append (item->priv->contributors,
+ grss_person_ref (contributor));
}
/**
diff --git a/src/feed-pie-handler.c b/src/feed-pie-handler.c
index 84e27a7..b15e192 100644
--- a/src/feed-pie-handler.c
+++ b/src/feed-pie-handler.c
@@ -252,11 +252,13 @@ parse_entry (FeedPieHandler *parser, GrssFeedChannel *feed, xmlDocPtr doc, xmlNo
/* parse feed author */
person = parseAuthor (cur);
grss_feed_item_set_author (item, person);
+ grss_person_unref (person);
}
else if (!xmlStrcmp (cur->name, BAD_CAST"contributor")) {
/* parse feed contributors */
person = parseAuthor (cur);
grss_feed_item_add_contributor (item, person);
+ grss_person_unref (person);
}
else if (!xmlStrcmp (cur->name, BAD_CAST"id")) {
if (NULL != (tmp = (gchar*) xmlNodeListGetString (doc, cur->xmlChildrenNode, 1))) {
@@ -377,8 +379,10 @@ feed_pie_handler_parse (FeedHandler *self, GrssFeedChannel *feed, xmlDocPtr doc,
else if (!xmlStrcmp (cur->name, BAD_CAST"author")) {
/* parse feed author */
person = parseAuthor (cur);
- if (person)
+ if (person) {
grss_feed_channel_set_editor (feed, person);
+ grss_person_unref (person);
+ }
}
else if (!xmlStrcmp (cur->name, BAD_CAST"tagline")) {
tmp = pie_parse_content_construct (cur);
@@ -436,8 +440,10 @@ feed_pie_handler_parse (FeedHandler *self, GrssFeedChannel *feed, xmlDocPtr doc,
}
else if (!xmlStrcmp (cur->name, BAD_CAST"contributor")) {
person = parseAuthor (cur);
- if (person)
+ if (person) {
grss_feed_channel_add_contributor (feed, person);
+ grss_person_unref (person);
+ }
}
else if (do_items == TRUE && (!xmlStrcmp (cur->name, BAD_CAST"entry"))) {
item = parse_entry (parser, feed, doc, cur);
diff --git a/src/feed-rss-handler.c b/src/feed-rss-handler.c
index 61d9c99..879e9ff 100644
--- a/src/feed-rss-handler.c
+++ b/src/feed-rss-handler.c
@@ -179,7 +179,11 @@ parse_channel (FeedRssHandler *parser, GrssFeedChannel *feed, xmlDocPtr doc, xml
else if (!xmlStrcmp (cur->name, BAD_CAST"managingEditor")) {
tmp = (gchar*) xmlNodeListGetString (doc, cur->xmlChildrenNode, 1);
if (tmp) {
- grss_feed_channel_set_editor (feed, grss_person_new (tmp, NULL, NULL));
+ GrssPerson *person;
+
+ person = grss_person_new (tmp, NULL, NULL);
+ grss_feed_channel_set_editor (feed, person);
+ grss_person_unref (person);
g_free (tmp);
}
}
@@ -288,8 +292,11 @@ parse_rss_item (FeedRssHandler *parser, GrssFeedChannel *feed, xmlDocPtr doc, xm
else if (!xmlStrcmp (cur->name, BAD_CAST"author")) {
tmp = (gchar*) xmlNodeListGetString (doc, cur->xmlChildrenNode, 1);
if (tmp) {
- grss_feed_item_set_author (item,
- grss_person_new (tmp, NULL, NULL));
+ GrssPerson *person;
+
+ person = grss_person_new (tmp, NULL, NULL);
+ grss_feed_item_set_author (item, person);
+ grss_person_unref (person);
g_free (tmp);
}
}
diff --git a/src/ns-handler.c b/src/ns-handler.c
index b8e6e05..3b65144 100644
--- a/src/ns-handler.c
+++ b/src/ns-handler.c
@@ -110,7 +110,9 @@ ns_dc_item (GrssFeedItem *item, xmlNodePtr cur)
grss_feed_item_set_title (item, value);
}
else if (!xmlStrcmp (BAD_CAST "creator", cur->name)) {
- grss_feed_item_set_author (item, grss_person_new (value, NULL, NULL));
+ GrssPerson *person = grss_person_new (value, NULL, NULL);
+ grss_feed_item_set_author (item, person);
+ grss_person_unref (person);
}
else if (!xmlStrcmp (BAD_CAST "subject", cur->name)) {
grss_feed_item_add_category (item, value);
@@ -119,7 +121,9 @@ ns_dc_item (GrssFeedItem *item, xmlNodePtr cur)
grss_feed_item_set_description (item, value);
}
else if (!xmlStrcmp (BAD_CAST "contributor", cur->name)) {
- grss_feed_item_add_contributor (item, grss_person_new (value, NULL, NULL));
+ GrssPerson *person = grss_person_new (value, NULL, NULL);
+ grss_feed_item_add_contributor (item, person);
+ grss_person_unref (person);
}
else if (!xmlStrcmp (BAD_CAST "rights", cur->name)) {
grss_feed_item_set_copyright (item, value);
@@ -144,7 +148,9 @@ ns_dc_channel (GrssFeedChannel *feed, xmlNodePtr cur)
ret = TRUE;
}
else if (!xmlStrcmp (BAD_CAST "creator", cur->name)) {
- grss_feed_channel_set_editor (feed, grss_person_new (value, NULL, NULL));
+ GrssPerson *person = grss_person_new (value, NULL, NULL);
+ grss_feed_channel_set_editor (feed, person);
+ grss_person_unref (person);
ret = TRUE;
}
else if (!xmlStrcmp (BAD_CAST "subject", cur->name)) {
@@ -160,7 +166,9 @@ ns_dc_channel (GrssFeedChannel *feed, xmlNodePtr cur)
ret = TRUE;
}
else if (!xmlStrcmp (BAD_CAST "contributor", cur->name)) {
- grss_feed_channel_add_contributor (feed, grss_person_new (value, NULL, NULL));
+ GrssPerson *person = grss_person_new (value, NULL, NULL);
+ grss_feed_channel_add_contributor (feed, person);
+ grss_person_unref (person);
ret = TRUE;
}
else if (!xmlStrcmp (BAD_CAST "rights", cur->name)) {
@@ -235,7 +243,9 @@ ns_itunes_item (GrssFeedItem *item, xmlNodePtr cur)
if (!xmlStrcmp (cur->name, BAD_CAST"author")) {
tmp = (gchar*) xmlNodeListGetString (cur->doc, cur->xmlChildrenNode, 1);
if (tmp) {
- grss_feed_item_set_author (item, grss_person_new (tmp, NULL, NULL));
+ GrssPerson *person = grss_person_new (tmp, NULL, NULL);
+ grss_feed_item_set_author (item, person);
+ grss_person_unref (person);
g_free (tmp);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]