Updating branch refs/heads/master to bb9cc2acb6f9038d3af9fa60677324607485b1c2 (commit) from 189bb0d6f014fafdaadb0f6b5e45ca395d37ae61 (commit)
commit bb9cc2acb6f9038d3af9fa60677324607485b1c2 Author: Harald Judt <h.j...@gmx.at> Date: Sun Dec 9 19:24:25 2012 +0100 Add make_timeslice() helper function. panel-plugin/weather-parsers.c | 25 ++++++++++++++++++++----- panel-plugin/weather-parsers.h | 2 ++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/panel-plugin/weather-parsers.c b/panel-plugin/weather-parsers.c index 187ef3d..f51b5f3 100644 --- a/panel-plugin/weather-parsers.c +++ b/panel-plugin/weather-parsers.c @@ -198,6 +198,24 @@ parse_location(xmlNode *cur_node, } +xml_time * +make_timeslice(void) +{ + xml_time *timeslice; + + timeslice = g_slice_new0(xml_time); + if (G_UNLIKELY(timeslice == NULL)) + return NULL; + + timeslice->location = g_slice_new0(xml_location); + if (G_UNLIKELY(timeslice->location == NULL)) { + g_slice_free(xml_time, timeslice); + return NULL; + } + return timeslice; +} + + static void parse_time(xmlNode *cur_node, xml_weather *wd) @@ -228,7 +246,7 @@ parse_time(xmlNode *cur_node, /* look for existing timeslice or add a new one */ timeslice = get_timeslice(wd, start_t, end_t); if (! timeslice) { - timeslice = g_slice_new0(xml_time); + timeslice = make_timeslice(); if (G_UNLIKELY(!timeslice)) return; timeslice->start = start_t; @@ -238,11 +256,8 @@ parse_time(xmlNode *cur_node, for (child_node = cur_node->children; child_node; child_node = child_node->next) - if (G_LIKELY(NODE_IS_TYPE(child_node, "location"))) { - if (timeslice->location == NULL) - timeslice->location = g_slice_new0(xml_location); + if (G_LIKELY(NODE_IS_TYPE(child_node, "location"))) parse_location(child_node, timeslice->location); - } } diff --git a/panel-plugin/weather-parsers.h b/panel-plugin/weather-parsers.h index bd377eb..a7c8fd6 100644 --- a/panel-plugin/weather-parsers.h +++ b/panel-plugin/weather-parsers.h @@ -121,6 +121,8 @@ typedef struct { } xml_timezone; +xml_time *make_timeslice(void); + void parse_weather(xmlNode *cur_node, xml_weather *wd); _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org https://mail.xfce.org/mailman/listinfo/xfce4-commits