From 0d8749b7cc2e1fb7bf1fcaf88738d4b083504b9f Mon Sep 17 00:00:00 2001 From: Andrej Kacian Date: Wed, 13 Mar 2019 21:58:56 +0100 Subject: [PATCH] Remove mgu_free_list() and mgu_free_dlist() We depend on glib 2.28, which has g_slist_free_full() and g_list_free_full(), which we can use instead. --- src/addressbook.c | 2 +- src/addrharvest.c | 4 ++-- src/addrindex.c | 2 +- src/common/mgutils.c | 26 -------------------------- src/common/mgutils.h | 2 -- src/editjpilot.c | 2 +- src/editldap.c | 2 +- src/editldap_basedn.c | 2 +- src/jpilot.c | 4 ++-- src/ldapctrl.c | 2 +- src/ldapquery.c | 12 ++++++------ src/ldif.c | 10 +++++----- src/mutt.c | 8 ++++---- src/pine.c | 4 ++-- src/vcard.c | 10 +++++----- 15 files changed, 32 insertions(+), 60 deletions(-) diff --git a/src/addressbook.c b/src/addressbook.c index 9f9e28797..bdbf3a8f3 100644 --- a/src/addressbook.c +++ b/src/addressbook.c @@ -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; } } diff --git a/src/addrharvest.c b/src/addrharvest.c index 32e46f9d0..5e6cbeb89 100644 --- a/src/addrharvest.c +++ b/src/addrharvest.c @@ -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 */ diff --git a/src/addrindex.c b/src/addrindex.c index dff2c934d..d44924c11 100644 --- a/src/addrindex.c +++ b/src/addrindex.c @@ -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; } diff --git a/src/common/mgutils.c b/src/common/mgutils.c index 8b90eab1a..9bdb2b12a 100644 --- a/src/common/mgutils.c +++ b/src/common/mgutils.c @@ -57,32 +57,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. */ diff --git a/src/common/mgutils.h b/src/common/mgutils.h index f589458b7..90c5d8051 100644 --- a/src/common/mgutils.h +++ b/src/common/mgutils.h @@ -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 ); diff --git a/src/editjpilot.c b/src/editjpilot.c index 631ef74f3..10331e5f3 100644 --- a/src/editjpilot.c +++ b/src/editjpilot.c @@ -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; } diff --git a/src/editldap.c b/src/editldap.c index 9272d98e8..8b5cf7c3c 100644 --- a/src/editldap.c +++ b/src/editldap.c @@ -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 { diff --git a/src/editldap_basedn.c b/src/editldap_basedn.c index 6fcaedae5..295b17298 100644 --- a/src/editldap_basedn.c +++ b/src/editldap_basedn.c @@ -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; diff --git a/src/jpilot.c b/src/jpilot.c index 7b37c37f7..9923d766d 100644 --- a/src/jpilot.c +++ b/src/jpilot.c @@ -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; } } diff --git a/src/ldapctrl.c b/src/ldapctrl.c index 4cb929eb9..bdba4ffec 100644 --- a/src/ldapctrl.c +++ b/src/ldapctrl.c @@ -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; } diff --git a/src/ldapquery.c b/src/ldapquery.c index 2e968311b..f79959908 100644 --- a/src/ldapquery.c +++ b/src/ldapquery.c @@ -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 ); diff --git a/src/ldif.c b/src/ldif.c index d2b19eff2..086ab0b2c 100644 --- a/src/ldif.c +++ b/src/ldif.c @@ -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; } diff --git a/src/mutt.c b/src/mutt.c index c6224c8c6..0747cf512 100644 --- a/src/mutt.c +++ b/src/mutt.c @@ -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; } diff --git a/src/pine.c b/src/pine.c index 19e252540..1e5df3d6b 100644 --- a/src/pine.c +++ b/src/pine.c @@ -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; } diff --git a/src/vcard.c b/src/vcard.c index df417a891..463f4a35d 100644 --- a/src/vcard.c +++ b/src/vcard.c @@ -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; } -- 2.25.1