diff options
| author | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2009-05-10 14:21:20 +0200 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2009-05-10 14:21:20 +0200 |
| commit | 8a722d04938583dc3620de05fd52f0baecce9fbb (patch) | |
| tree | dfee5472e5a88c450b8cc4abc71cc2a68d635e67 /src/items.c | |
| parent | 3bca7e95f2b4ef351b89495afcb6d6230b5f7cd0 (diff) | |
| download | cataract-8a722d04938583dc3620de05fd52f0baecce9fbb.tar.xz | |
Consolidate data types
Diffstat (limited to 'src/items.c')
| -rw-r--r-- | src/items.c | 88 |
1 files changed, 35 insertions, 53 deletions
diff --git a/src/items.c b/src/items.c index 27034f2..842f066 100644 --- a/src/items.c +++ b/src/items.c @@ -34,23 +34,23 @@ * parse_album_xml: XML parser for gallery index.xml files */ gboolean -parse_album_xml (const char *filename, TAlbum *index) +parse_album_xml (const gchar *filename, TAlbum *index) { TXMLFile *xml; - char *gallery_type; + gchar *gallery_type; int count; int i; - char *s, *s2; - char *node_name; + gchar *s, *s2; + gchar *node_name; TIndexItem *item; xml = xml_parser_load (filename); if (xml == NULL) - return FALSE; + return FALSE; /* Initialize data struct */ if (index == NULL) - index = malloc (sizeof (TAlbum)); + index = g_malloc0 (sizeof (TAlbum)); memset (index, 0, sizeof (TAlbum)); index->base_dir = g_path_get_dirname (filename); @@ -61,13 +61,13 @@ parse_album_xml (const char *filename, TAlbum *index) printf("gallery_type = %s\n", gallery_type); #endif if (strcmp (gallery_type, "index") == 0) - index->type = GALLERY_TYPE_INDEX; + index->type = GALLERY_TYPE_INDEX; else if (strcmp (gallery_type, "album") == 0) - index->type = GALLERY_TYPE_ALBUM; + index->type = GALLERY_TYPE_ALBUM; else { log_error ("Invalid gallery type (%s)\n", gallery_type); - free (index); + g_free (index); return FALSE; } @@ -79,7 +79,7 @@ parse_album_xml (const char *filename, TAlbum *index) s = xml_file_get_node_value (xml, "/gallery/general/extra_files/text()"); if (s) { index->extra_files = g_strsplit (s, "\n", -1); - free (s); + g_free (s); } @@ -184,7 +184,7 @@ parse_album_xml (const char *filename, TAlbum *index) else { log_error ("%s: No image src specified, skipping!\n", filename); - free (item); + g_free (item); } } else @@ -209,9 +209,9 @@ parse_album_xml (const char *filename, TAlbum *index) } else { /* Free the item if nobody cares */ - free (item); + g_free (item); } - free (node_name); + g_free (node_name); } xml_parser_close (xml); @@ -236,26 +236,16 @@ void free_album_data (TAlbum *album) { if (album) { - if (album->ID) - free (album->ID); - if (album->title) - free (album->title); - if (album->desc) - free (album->desc); - if (album->footnote) - free (album->footnote); - if (album->base_dir) - free (album->base_dir); - if (album->border_style) - free (album->border_style); - if (album->meta_author) - free (album->meta_author); - if (album->meta_description) - free (album->meta_description); - if (album->meta_keywords) - free (album->meta_keywords); - if (album->extra_files) - g_strfreev (album->extra_files); + g_free (album->ID); + g_free (album->title); + g_free (album->desc); + g_free (album->footnote); + g_free (album->base_dir); + g_free (album->border_style); + g_free (album->meta_author); + g_free (album->meta_description); + g_free (album->meta_keywords); + g_strfreev (album->extra_files); if (album->items) { if (album->items->len > 0) { @@ -265,29 +255,21 @@ free_album_data (TAlbum *album) for (i = 0; i < album->items->len; i++) { item = g_ptr_array_index (album->items, i); if (item != NULL) { - if (item->path) - free (item->path); - if (item->title) - free (item->title); - if (item->title_description) - free (item->title_description); - if (item->thumbnail) - free (item->thumbnail); - if (item->preview) - free (item->preview); - if (item->border_style) - free (item->border_style); - if (item->gen_img_src) - free (item->gen_img_src); - if (item->gen_thumb) - free (item->gen_thumb); - free (item); + g_free (item->path); + g_free (item->title); + g_free (item->title_description); + g_free (item->thumbnail); + g_free (item->preview); + g_free (item->border_style); + g_free (item->gen_img_src); + g_free (item->gen_thumb); + g_free (item); } } } g_ptr_array_free (album->items, TRUE); } - free (album); + g_free (album); album = NULL; } } @@ -297,7 +279,7 @@ free_album_data (TAlbum *album) * get_gallery_objects_count: retrieve number of items in specified album */ int -get_album_objects_count (const char *filename) +get_album_objects_count (const gchar *filename) { TXMLFile *xml; int count; @@ -319,7 +301,7 @@ get_album_objects_count (const char *filename) * get_album_titles: retrieve title, description and first thumbnail from specified album */ void -get_album_titles (const char *filename, char **title, char **description, char **thumbnail) +get_album_titles (const gchar *filename, gchar **title, gchar **description, gchar **thumbnail) { TXMLFile *xml; |
