# HG changeset patch # User rosfran # Date 1159280629 -3600 # Node ID 79e798d40577cda52a34b2008e2db7fc33f72855 # Parent 00c73ffe40ad24677607a435ea12d667ab6fbb96 [svn r12] Do some code cleaning, freeing buffer. diff -r 00c73ffe40ad -r 79e798d40577 gmyth/src/libgmyth/gmyth_stringlist.c --- a/gmyth/src/libgmyth/gmyth_stringlist.c Sat Sep 23 01:11:47 2006 +0100 +++ b/gmyth/src/libgmyth/gmyth_stringlist.c Tue Sep 26 15:23:49 2006 +0100 @@ -195,7 +195,7 @@ g_return_val_if_fail( tmp_str != NULL && tmp_str->str != NULL, 0 ); - return (int) ( 0x00000000ffffffffL & g_ascii_strtoull ( tmp_str->str, NULL, 0 ) ); + return (gint) ( 0x00000000ffffffffL & g_ascii_strtoull ( tmp_str->str, NULL, 0 ) ); } /** Gets a guint64 value from the string list at the given position. diff -r 00c73ffe40ad -r 79e798d40577 gmyth/src/libgmyth/gmyth_tvchain.c --- a/gmyth/src/libgmyth/gmyth_tvchain.c Sat Sep 23 01:11:47 2006 +0100 +++ b/gmyth/src/libgmyth/gmyth_tvchain.c Tue Sep 26 15:23:49 2006 +0100 @@ -70,8 +70,23 @@ static void gmyth_tvchain_dispose (GObject *object) { - //GMythTVChain *tvchain = GMYTH_TVCHAIN(object); - + GMythTVChain *tvchain = GMYTH_TVCHAIN(object); + + if ( tvchain->tvchain_id != NULL ) { + g_string_free( tvchain->tvchain_id, TRUE ); + tvchain->tvchain_id = NULL; + } + + if ( tvchain->tvchain_list != NULL ) { + g_list_free( tvchain->tvchain_list ); + tvchain->tvchain_list = NULL; + } + + if ( tvchain->cur_chanid != NULL ) { + g_string_free( tvchain->cur_chanid, TRUE ); + tvchain->cur_chanid = NULL; + } + G_OBJECT_CLASS (gmyth_tvchain_parent_class)->dispose (object); } @@ -119,6 +134,8 @@ GString* gmyth_tvchain_get_id (GMythTVChain *tvchain) { + g_return_val_if_fail( tvchain != NULL && tvchain->tvchain_id != NULL, NULL ); + return g_string_new (tvchain->tvchain_id->str); } @@ -133,6 +150,7 @@ MYSQL_ROW msql_row; MYSQL_RES *msql_res; GMythQuery *gmyth_query; + gboolean ret = TRUE; GString *stmt_str; @@ -142,8 +160,10 @@ g_debug ("[%s] chainid: %s", __FUNCTION__, tvchain->tvchain_id->str); - g_list_free (tvchain->tvchain_list); - tvchain->tvchain_list = NULL; + if ( tvchain != NULL && tvchain->tvchain_list != NULL ) { + g_list_free (tvchain->tvchain_list); + tvchain->tvchain_list = NULL; + } // TODO: Reuse gmyth_query already connected from context gmyth_query = gmyth_query_new (); @@ -151,7 +171,9 @@ g_warning ("[%s] Could not connect to db", __FUNCTION__); g_static_mutex_unlock( &mutex ); - return FALSE; + ret = FALSE; + + goto done; } stmt_str = g_string_new (""); @@ -184,7 +206,8 @@ g_warning ("gmyth_tvchain_reload_all query error!\n"); g_static_mutex_unlock( &mutex ); - return FALSE; + ret = FALSE; + goto done; } g_static_mutex_unlock( &mutex ); @@ -201,13 +224,17 @@ g_debug ("[%s] Added new recording", __FUNCTION__); } - g_string_free (stmt_str, TRUE); +done: + if ( stmt_str != NULL ) + g_string_free (stmt_str, TRUE); - mysql_free_result (msql_res); + if ( msql_res != NULL ) + mysql_free_result (msql_res); - g_object_unref (gmyth_query); + if ( gmyth_query != NULL ) + g_object_unref (gmyth_query); - return TRUE; + return ret; } /** Returns the internal index for the TV chain related to the given @@ -270,6 +297,8 @@ gmyth_tvchain_get_entry_at (GMythTVChain *tvchain, int index) { struct LiveTVChainEntry* chain_entry = NULL; + + g_return_val_if_fail( tvchain != NULL && tvchain->tvchain_list != NULL, NULL ); g_static_mutex_lock( &mutex ); @@ -302,6 +331,8 @@ { GMythProgramInfo *proginfo = NULL; + g_return_val_if_fail( tvchain != NULL, NULL ); + if (!entry || !tvchain) { g_warning ("gmyth_tvchain_entry_to_program() received NULL argument"); return NULL;