[svn r12] Do some code cleaning, freeing buffer.
1.1 --- a/gmyth/src/libgmyth/gmyth_stringlist.c Sat Sep 23 01:11:47 2006 +0100
1.2 +++ b/gmyth/src/libgmyth/gmyth_stringlist.c Tue Sep 26 15:23:49 2006 +0100
1.3 @@ -195,7 +195,7 @@
1.4
1.5 g_return_val_if_fail( tmp_str != NULL && tmp_str->str != NULL, 0 );
1.6
1.7 - return (int) ( 0x00000000ffffffffL & g_ascii_strtoull ( tmp_str->str, NULL, 0 ) );
1.8 + return (gint) ( 0x00000000ffffffffL & g_ascii_strtoull ( tmp_str->str, NULL, 0 ) );
1.9 }
1.10
1.11 /** Gets a guint64 value from the string list at the given position.
2.1 --- a/gmyth/src/libgmyth/gmyth_tvchain.c Sat Sep 23 01:11:47 2006 +0100
2.2 +++ b/gmyth/src/libgmyth/gmyth_tvchain.c Tue Sep 26 15:23:49 2006 +0100
2.3 @@ -70,8 +70,23 @@
2.4 static void
2.5 gmyth_tvchain_dispose (GObject *object)
2.6 {
2.7 - //GMythTVChain *tvchain = GMYTH_TVCHAIN(object);
2.8 -
2.9 + GMythTVChain *tvchain = GMYTH_TVCHAIN(object);
2.10 +
2.11 + if ( tvchain->tvchain_id != NULL ) {
2.12 + g_string_free( tvchain->tvchain_id, TRUE );
2.13 + tvchain->tvchain_id = NULL;
2.14 + }
2.15 +
2.16 + if ( tvchain->tvchain_list != NULL ) {
2.17 + g_list_free( tvchain->tvchain_list );
2.18 + tvchain->tvchain_list = NULL;
2.19 + }
2.20 +
2.21 + if ( tvchain->cur_chanid != NULL ) {
2.22 + g_string_free( tvchain->cur_chanid, TRUE );
2.23 + tvchain->cur_chanid = NULL;
2.24 + }
2.25 +
2.26 G_OBJECT_CLASS (gmyth_tvchain_parent_class)->dispose (object);
2.27 }
2.28
2.29 @@ -119,6 +134,8 @@
2.30 GString*
2.31 gmyth_tvchain_get_id (GMythTVChain *tvchain)
2.32 {
2.33 + g_return_val_if_fail( tvchain != NULL && tvchain->tvchain_id != NULL, NULL );
2.34 +
2.35 return g_string_new (tvchain->tvchain_id->str);
2.36 }
2.37
2.38 @@ -133,6 +150,7 @@
2.39 MYSQL_ROW msql_row;
2.40 MYSQL_RES *msql_res;
2.41 GMythQuery *gmyth_query;
2.42 + gboolean ret = TRUE;
2.43
2.44 GString *stmt_str;
2.45
2.46 @@ -142,8 +160,10 @@
2.47
2.48 g_debug ("[%s] chainid: %s", __FUNCTION__, tvchain->tvchain_id->str);
2.49
2.50 - g_list_free (tvchain->tvchain_list);
2.51 - tvchain->tvchain_list = NULL;
2.52 + if ( tvchain != NULL && tvchain->tvchain_list != NULL ) {
2.53 + g_list_free (tvchain->tvchain_list);
2.54 + tvchain->tvchain_list = NULL;
2.55 + }
2.56
2.57 // TODO: Reuse gmyth_query already connected from context
2.58 gmyth_query = gmyth_query_new ();
2.59 @@ -151,7 +171,9 @@
2.60 g_warning ("[%s] Could not connect to db", __FUNCTION__);
2.61 g_static_mutex_unlock( &mutex );
2.62
2.63 - return FALSE;
2.64 + ret = FALSE;
2.65 +
2.66 + goto done;
2.67 }
2.68
2.69 stmt_str = g_string_new ("");
2.70 @@ -184,7 +206,8 @@
2.71 g_warning ("gmyth_tvchain_reload_all query error!\n");
2.72 g_static_mutex_unlock( &mutex );
2.73
2.74 - return FALSE;
2.75 + ret = FALSE;
2.76 + goto done;
2.77 }
2.78
2.79 g_static_mutex_unlock( &mutex );
2.80 @@ -201,13 +224,17 @@
2.81 g_debug ("[%s] Added new recording", __FUNCTION__);
2.82 }
2.83
2.84 - g_string_free (stmt_str, TRUE);
2.85 +done:
2.86 + if ( stmt_str != NULL )
2.87 + g_string_free (stmt_str, TRUE);
2.88
2.89 - mysql_free_result (msql_res);
2.90 + if ( msql_res != NULL )
2.91 + mysql_free_result (msql_res);
2.92
2.93 - g_object_unref (gmyth_query);
2.94 + if ( gmyth_query != NULL )
2.95 + g_object_unref (gmyth_query);
2.96
2.97 - return TRUE;
2.98 + return ret;
2.99 }
2.100
2.101 /** Returns the internal index for the TV chain related to the given
2.102 @@ -270,6 +297,8 @@
2.103 gmyth_tvchain_get_entry_at (GMythTVChain *tvchain, int index)
2.104 {
2.105 struct LiveTVChainEntry* chain_entry = NULL;
2.106 +
2.107 + g_return_val_if_fail( tvchain != NULL && tvchain->tvchain_list != NULL, NULL );
2.108
2.109 g_static_mutex_lock( &mutex );
2.110
2.111 @@ -302,6 +331,8 @@
2.112 {
2.113 GMythProgramInfo *proginfo = NULL;
2.114
2.115 + g_return_val_if_fail( tvchain != NULL, NULL );
2.116 +
2.117 if (!entry || !tvchain) {
2.118 g_warning ("gmyth_tvchain_entry_to_program() received NULL argument");
2.119 return NULL;