From 1089f1fcf55591dd4b5d47ee963bfe0e24cf9ad5 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Sun, 12 Dec 2010 14:34:59 +0100 Subject: items: Cleanup --- src/items.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/items.c') diff --git a/src/items.c b/src/items.c index ea0e4e9..b31e9cd 100644 --- a/src/items.c +++ b/src/items.c @@ -72,8 +72,8 @@ free_album_item (TIndexItem *item) /* * parse_album_xml: XML parser for gallery index.xml files */ -gboolean -parse_album_xml (const gchar *filename, TAlbum *index) +TAlbum * +parse_album_xml (const gchar *filename) { TXMLFile *xml; gchar *gallery_type; @@ -83,11 +83,13 @@ parse_album_xml (const gchar *filename, TAlbum *index) gchar *node_name; TIndexItem *item; TAtomFeedItem *feed_item; + TAlbum *index; xml = xml_parser_load (filename); if (xml == NULL) - return FALSE; + return NULL; + index = g_malloc0 (sizeof (TAlbum)); index->base_dir = g_path_get_dirname (filename); /* Retrieve gallery type */ @@ -100,8 +102,8 @@ parse_album_xml (const gchar *filename, TAlbum *index) else { log_error ("Invalid gallery type (%s)\n", gallery_type); g_free (gallery_type); - g_free (index); - return FALSE; + free_album_data (index); + return NULL; } g_free (gallery_type); @@ -175,8 +177,7 @@ parse_album_xml (const gchar *filename, TAlbum *index) if (! node_name) continue; - item = malloc (sizeof (TIndexItem)); - memset (item, 0, sizeof (TIndexItem)); + item = g_malloc0 (sizeof (TIndexItem)); if (strcmp (node_name, "item") == 0) { item->type = INDEX_ITEM_TYPE_PICTURE; @@ -279,7 +280,7 @@ parse_album_xml (const gchar *filename, TAlbum *index) } xml_parser_close (xml); - return TRUE; + return index; } -- cgit v1.2.3