diff options
| -rw-r--r-- | src/items.c | 17 | ||||
| -rw-r--r-- | src/items.h | 2 | ||||
| -rw-r--r-- | src/job-manager.c | 9 |
3 files changed, 14 insertions, 14 deletions
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; } diff --git a/src/items.h b/src/items.h index ffad086..d1ef7d8 100644 --- a/src/items.h +++ b/src/items.h @@ -82,7 +82,7 @@ typedef struct { /* * 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); /* * free_album_data: free allocated album data diff --git a/src/job-manager.c b/src/job-manager.c index 87b3425..c4a77e4 100644 --- a/src/job-manager.c +++ b/src/job-manager.c @@ -225,15 +225,14 @@ build_tree (TGallerySetup *setup, } /* Read the index file and fill items array */ - items = g_malloc0 (sizeof (TAlbum)); - items->parent_index = parent_index; - items->parent_item_index = parent_item_index; - if (! parse_album_xml (idx_file, items)) { + items = parse_album_xml (idx_file); + if (! items) { log_error ("error reading index file '%s'\n", idx_file); g_free (idx_file); - free_album_data (items); return FALSE; } + items->parent_index = parent_index; + items->parent_item_index = parent_item_index; /* Check if update is necessary */ dst_album_file = g_strconcat (dst_dir, "/", setup->index_file_name, NULL); |
