Remove mgu_free_list() and mgu_free_dlist()
authorAndrej Kacian <ticho@claws-mail.org>
Wed, 13 Mar 2019 20:58:56 +0000 (21:58 +0100)
committerAndrej Kacian <ticho@claws-mail.org>
Wed, 13 Mar 2019 20:58:56 +0000 (21:58 +0100)
We depend on glib 2.28, which has g_slist_free_full()
and g_list_free_full(), which we can use instead.

15 files changed:
src/addressbook.c
src/addrharvest.c
src/addrindex.c
src/common/mgutils.c
src/common/mgutils.h
src/editjpilot.c
src/editldap.c
src/editldap_basedn.c
src/jpilot.c
src/ldapctrl.c
src/ldapquery.c
src/ldif.c
src/mutt.c
src/pine.c
src/vcard.c

index 9f9e287..bdbf3a8 100644 (file)
@@ -2389,7 +2389,7 @@ static void addressbook_mail_to_cb( GtkAction *action, gpointer data ) {
        if( ! addrselect_test_empty( _addressSelect_ ) ) {
                listAddress = addrselect_build_list( _addressSelect_ );
                compose_new_with_list( NULL, listAddress );
-               mgu_free_dlist( listAddress );
+               g_list_free_full( listAddress, g_free );
                listAddress = NULL;
        }
 }
index 32e46f9..5e6cbeb 100644 (file)
@@ -731,7 +731,7 @@ static gint addrharvest_readfile(
                }
 
                buf = mgu_list_coalesce( list );
-               mgu_free_list( list );
+               g_slist_free_full( list, g_free );
 
                if(( p = strchr( buf, ':' ) ) != NULL ) {
                        addr = p + 1;
@@ -891,7 +891,7 @@ gint addrharvest_harvest(
        else {
                addrharvest_harvest_list( harvester, cache, listHdr, msgList );
        }
-       mgu_free_dlist( listHdr );
+       g_list_free_full( listHdr, g_free );
 
 #ifndef USE_ALT_ADDRBOOK
        /* Mark cache */
index dff2c93..d44924c 100644 (file)
@@ -1295,7 +1295,7 @@ static void addrindex_parse_ldap_attrlist( XMLFile *file, LdapControl *ctl ) {
                rc = xml_parse_next_tag( file );
                if( rc != 0 ) {
                        /* Terminate prematurely */
-                       mgu_free_dlist( list );
+                       g_list_free_full( list, g_free );
                        list = NULL;
                        return;
                }
index 8b90eab..9bdb2b1 100644 (file)
@@ -58,32 +58,6 @@ void mgu_print_dlist( GList *list, FILE *stream ) {
 }
 
 /*
-* Free linked list of character strings.
-*/
-void mgu_free_list( GSList *list ) {
-       GSList *node = list;
-       while( node ) {
-               g_free( node->data );
-               node->data = NULL;
-               node = g_slist_next( node );
-       }
-       g_slist_free( list );
-}
-
-/*
-* Free linked list of character strings.
-*/
-void mgu_free_dlist( GList *list ) {
-       GList *node = list;
-       while( node ) {
-               g_free( node->data );
-               node->data = NULL;
-               node = g_list_next( node );
-       }
-       g_list_free( list );
-}
-
-/*
 * Coalesce linked list of characaters into one long string.
 */
 gchar *mgu_list_coalesce( GSList *list ) {
index f589458..90c5d80 100644 (file)
@@ -43,8 +43,6 @@
 /* Function prototypes */
 void mgu_print_list            ( GSList *list, FILE *stream );
 void mgu_print_dlist           ( GList *list, FILE *stream );
-void mgu_free_list             ( GSList *list );
-void mgu_free_dlist            ( GList *list );
 gchar *mgu_list_coalesce       ( GSList *list );
 gchar *mgu_replace_string      ( gchar *str, const gchar *value );
 gchar *mgu_email_check_empty   ( gchar *address );
index 631ef74..10331e5 100644 (file)
@@ -124,7 +124,7 @@ static void edit_jpilot_fill_check_box( JPilotFile *jpf ) {
                        done = TRUE;
                }
        }
-       mgu_free_dlist( customLbl );
+       g_list_free_full( customLbl, g_free );
        customLbl = NULL;
 }
 
index 9272d98..8b5cf7c 100644 (file)
@@ -254,7 +254,7 @@ static void edit_ldap_server_check( void ) {
                                        }
                                        node = g_list_next( node );
                                }
-                               mgu_free_dlist( baseDN );
+                               g_list_free_full( baseDN, g_free );
                                baseDN = node = NULL;
                                flg = TRUE;
                        } else {
index 6fcaeda..295b172 100644 (file)
@@ -311,7 +311,7 @@ static void edit_ldap_bdn_load_data(
                                if (gtk_tree_model_get_iter_first(model, &iter))
                                        gtk_tree_selection_select_iter(sel, &iter);
 
-                               mgu_free_dlist( baseDN );
+                               g_list_free_full( baseDN, g_free );
                                baseDN = node = NULL;
                        }
                        ldapedit_basedn_bad_server = FALSE;
index 7b37c37..9923d76 100644 (file)
@@ -256,7 +256,7 @@ void jpilot_clear_custom_labels( JPilotFile *pilotFile ) {
        cm_return_if_fail( pilotFile != NULL );
 
        /* Release custom labels */
-       mgu_free_dlist( pilotFile->customLabels );
+       g_list_free_full( pilotFile->customLabels, g_free );
        pilotFile->customLabels = NULL;
 
        /* Release indexes */
@@ -1079,7 +1079,7 @@ static void jpilot_parse_label( JPilotFile *pilotFile, gchar *labelEntry, ItemPe
                        addrcache_person_add_email( pilotFile->addressCache, person, email );
                        node = g_list_next( node );
                }
-               mgu_free_dlist( list );
+               g_list_free_full( list, g_free );
                list = NULL;
        }
 }
index 4cb929e..bdba4ff 100644 (file)
@@ -241,7 +241,7 @@ GList *ldapctl_get_criteria_list( const LdapControl* ctl ) {
  */
 void ldapctl_criteria_list_clear( LdapControl *ctl ) {
        cm_return_if_fail( ctl != NULL );
-       mgu_free_dlist( ctl->listCriteria );
+       g_list_free_full( ctl->listCriteria, g_free );
        ctl->listCriteria = NULL;
 }
 
index 2e96831..f799599 100644 (file)
@@ -370,11 +370,11 @@ static void ldapqry_free_lists(
                GSList *listLast, GSList *listDisplay, GSList *other_attrs )
 {
        GSList *cur = other_attrs;
-       mgu_free_list( listName );
-       mgu_free_list( listAddr );
-       mgu_free_list( listFirst );
-       mgu_free_list( listLast );
-       mgu_free_list( listDisplay );
+       g_slist_free_full( listName, g_free );
+       g_slist_free_full( listAddr, g_free );
+       g_slist_free_full( listFirst, g_free );
+       g_slist_free_full( listLast, g_free );
+       g_slist_free_full( listDisplay, g_free );
        for(;cur; cur = cur->next)
                addritem_free_attribute((UserAttribute *)cur->data);
        g_slist_free(other_attrs);
@@ -625,7 +625,7 @@ static GList *ldapqry_process_single_entry(
                                addritem_attrib_set_value( attrib, attvalue );
                                other_attrs = g_slist_prepend(other_attrs, attrib);
                        }
-                       mgu_free_list(attlist);
+                       g_slist_free_full(attlist, g_free);
                }
                /* Free memory used to store attribute */
                ldap_memfree( attribute );
index d2b19ef..086ab0b 100644 (file)
@@ -651,7 +651,7 @@ static void ldif_read_file( LdifFile *ldifFile, AddressCache *cache ) {
                                ldif_build_items( ldifFile, rec, cache );
                                ldif_clear_rec( rec );
                                g_free( lastTag );
-                               mgu_free_list( listValue );
+                               g_slist_free_full( listValue, g_free );
                                g_free(fullValue);
                                lastTag = NULL;
                                listValue = NULL;
@@ -696,7 +696,7 @@ static void ldif_read_file( LdifFile *ldifFile, AddressCache *cache ) {
                                                                rec, lastTag, fullValue,
                                                                hashField );
                                                        g_free( lastTag );
-                                                       mgu_free_list( listValue );
+                                                       g_slist_free_full( listValue, g_free );
                                                        lastTag = NULL;
                                                        listValue = NULL;
                                                }
@@ -719,7 +719,7 @@ static void ldif_read_file( LdifFile *ldifFile, AddressCache *cache ) {
        ldif_clear_rec( rec );
        g_free( rec );
        g_free( lastTag );
-       mgu_free_list( listValue );
+       g_slist_free_full( listValue, g_free );
 }
 
 /**
@@ -854,7 +854,7 @@ static void ldif_read_tag_list( LdifFile *ldifFile ) {
                                ldif_hash_add_list(
                                        ldifFile->hashFields, listTags );
                        }
-                       mgu_free_list( listTags );
+                       g_slist_free_full( listTags, g_free );
                        listTags = NULL;
                        flagMail = FALSE;
                }
@@ -891,7 +891,7 @@ static void ldif_read_tag_list( LdifFile *ldifFile ) {
        }
 
        /* Release data */
-       mgu_free_list( listTags );
+       g_slist_free_full( listTags, g_free );
        listTags = NULL;
 }
 
index c6224c8..0747cf5 100644 (file)
@@ -416,7 +416,7 @@ static void mutt_build_items( MuttFile *muttFile, AddressCache *cache, gchar *li
        list = mgu_parse_string( line,  3, &tCount );
        if( tCount < 3 ) {
                if( list ) {
-                       mgu_free_dlist( list );
+                       g_list_free_full( list, g_free );
                        list = NULL;
                }
                return;
@@ -438,7 +438,7 @@ static void mutt_build_items( MuttFile *muttFile, AddressCache *cache, gchar *li
                mutt_build_address( muttFile, cache, aliasName, addrList, aCount );
        }
 
-       mgu_free_dlist( list );
+       g_list_free_full( list, g_free );
        list = NULL;
 
 }
@@ -479,7 +479,7 @@ static void mutt_read_file( MuttFile *muttFile, AddressCache *cache ) {
                        }
                        g_free( lineValue );
                        lineValue = NULL;
-                       mgu_free_list( listValue );
+                       g_slist_free_full( listValue, g_free );
                        listValue = NULL;
                }
                lastCont = flagCont;
@@ -492,7 +492,7 @@ static void mutt_read_file( MuttFile *muttFile, AddressCache *cache ) {
        }
 
        /* Release data */
-       mgu_free_list( listValue );
+       g_slist_free_full( listValue, g_free );
        listValue = NULL;
 }
 
index 19e2525..1e5df3d 100644 (file)
@@ -576,7 +576,7 @@ static void pine_read_file( PineFile *pineFile, AddressCache *cache ) {
                                }
                                g_free( lineValue );
                                lineValue = NULL;
-                               mgu_free_list( listValue );
+                               g_slist_free_full( listValue, g_free );
                                listValue = NULL;
                        }
                        if( line != NULL ) {
@@ -591,7 +591,7 @@ static void pine_read_file( PineFile *pineFile, AddressCache *cache ) {
        }
 
        /* Release data */
-       mgu_free_list( listValue );
+       g_slist_free_full( listValue, g_free );
        listValue = NULL;
 }
 
index df417a8..463f4a3 100644 (file)
@@ -248,10 +248,10 @@ static gchar *vcard_get_line( VCardFile *cardFile ) {
 * Free linked lists of character strings.
 */
 static void vcard_free_lists( GSList *listName, GSList *listAddr, GSList *listRem, GSList* listID ) {
-       mgu_free_list( listName );
-       mgu_free_list( listAddr );
-       mgu_free_list( listRem );
-       mgu_free_list( listID );
+       g_slist_free_full( listName, g_free );
+       g_slist_free_full( listAddr, g_free );
+       g_slist_free_full( listRem, g_free );
+       g_slist_free_full( listID, g_free );
 }
 
 /*
@@ -275,7 +275,7 @@ static gchar *vcard_read_qp( VCardFile *cardFile, char *tagvalue ) {
        line = mgu_list_coalesce( listQP );
 
        /* Clean up */
-       mgu_free_list( listQP );
+       g_slist_free_full( listQP, g_free );
        listQP = NULL;
        return line;
 }