[svn r226] Some fixes on the g_malloc'ing/g_free'ing usage on the code.
1.1 --- a/gmyth/src/gmyth_livetv.c Mon Dec 18 22:19:58 2006 +0000
1.2 +++ b/gmyth/src/gmyth_livetv.c Tue Dec 19 16:25:25 2006 +0000
1.3 @@ -324,6 +324,12 @@
1.4 gmyth_debug ("GMythLiveTV: All requests to backend to start TV were OK. [%s]\n", livetv->proginfo->pathname->str );
1.5 }
1.6
1.7 + if ( !gmyth_livetv_monitor_handler_start( livetv ) )
1.8 + {
1.9 + res = FALSE;
1.10 + goto error;
1.11 + }
1.12 +
1.13 livetv->setup_done = TRUE;
1.14
1.15 return res;
1.16 @@ -463,9 +469,6 @@
1.17 goto done;
1.18 }
1.19
1.20 - if ( !gmyth_livetv_monitor_handler_start( livetv ) )
1.21 - goto done;
1.22 -
1.23 done:
1.24 if ( uri != NULL )
1.25 {
2.1 --- a/gmyth/src/gmyth_monitor_handler.c Mon Dec 18 22:19:58 2006 +0000
2.2 +++ b/gmyth/src/gmyth_monitor_handler.c Tue Dec 19 16:25:25 2006 +0000
2.3 @@ -283,7 +283,7 @@
2.4 gmyth_debug ("Monitor event socket --- hostname: %s, port %d\n", monitor->hostname, monitor->port);
2.5
2.6 /* configure the event socket */
2.7 - if (monitor->event_sock == NULL) {
2.8 + if ( NULL == monitor->event_sock ) {
2.9 if (!gmyth_connect_to_backend_monitor (monitor)) {
2.10 g_printerr( "Connection to backend failed (Event Socket).\n" );
2.11 ret = FALSE;
3.1 --- a/gmyth/src/gmyth_socket.c Mon Dec 18 22:19:58 2006 +0000
3.2 +++ b/gmyth/src/gmyth_socket.c Tue Dec 19 16:25:25 2006 +0000
3.3 @@ -42,6 +42,7 @@
3.4 #include <arpa/inet.h>
3.5 #include <sys/types.h>
3.6 #include <sys/socket.h>
3.7 +#include <sys/param.h>
3.8 #include <netdb.h>
3.9 #include <net/if.h>
3.10 #include <errno.h>
3.11 @@ -114,7 +115,8 @@
3.12 struct addrinfo *hints;
3.13 gchar *portStr = NULL;
3.14 gint errorn = EADDRNOTAVAIL;
3.15 -
3.16 +
3.17 + g_return_val_if_fail (addr != NULL, -1);
3.18
3.19 hints = g_new0 (struct addrinfo, 1);
3.20 hints->ai_family = AF_INET;
3.21 @@ -307,13 +309,18 @@
3.22 if ( local_hostname != NULL )
3.23 return g_string_new( local_hostname );
3.24
3.25 - gchar localhostname[1024];
3.26 gchar *localaddr = NULL;
3.27 gboolean found_addr = FALSE;
3.28 struct addrinfo* addr_info_data = NULL, *addr_info0 = NULL;
3.29 struct sockaddr_in* sa = NULL;
3.30 + gchar localhostname[MAXHOSTNAMELEN];
3.31
3.32 - gethostname (localhostname, 1024);
3.33 + if (gethostname (localhostname, MAXHOSTNAMELEN) != 0 ) {
3.34 + g_warning ("Error on gethostname");
3.35 + }
3.36 + localhostname[MAXHOSTNAMELEN-1] = 0;
3.37 +
3.38 +
3.39 gint err = gmyth_socket_toaddrinfo (localhostname, -1, &addr_info_data );
3.40
3.41 if ( err == EADDRNOTAVAIL )
3.42 @@ -333,8 +340,15 @@
3.43 if ( localaddr != NULL && ( g_strrstr( localaddr, "127" ) == NULL ) ) {
3.44 str = g_string_new (localaddr);
3.45 found_addr = TRUE;
3.46 + g_free (localaddr);
3.47 break;
3.48 }
3.49 +
3.50 + if (localaddr != NULL) {
3.51 + g_free (localaddr);
3.52 + localaddr = NULL;
3.53 + }
3.54 +
3.55 addr_info0 = addr_info0->ai_next;
3.56 };
3.57 freeaddrinfo (addr_info_data);
3.58 @@ -343,7 +357,7 @@
3.59 gchar *prim_addr = gmyth_socket_get_primary_addr();
3.60
3.61 if ( prim_addr != NULL ) {
3.62 - g_warning("[%s] Could not determine the local alphanumerical hostname. Setting to %s\n",
3.63 + g_warning("[%s] Could not determine the local alphanumerical hostname. Setting to %s\n",
3.64 __FUNCTION__, prim_addr );
3.65
3.66 str = g_string_new (prim_addr);
3.67 @@ -357,7 +371,7 @@
3.68
3.69 if ( str != NULL && str->str != NULL )
3.70 local_hostname = g_strdup( str->str );
3.71 -
3.72 +
3.73 return str;
3.74 }
3.75
3.76 @@ -502,12 +516,10 @@
3.77 gint errno;
3.78 gboolean ret = TRUE;
3.79
3.80 + gmyth_debug ("CONNECTING %s:%d", hostname, port);
3.81 +
3.82 if ( hostname == NULL )
3.83 - g_printerr ( "[%s] Invalid hostname parameter!\n", __FUNCTION__ );
3.84 -
3.85 - errno = gmyth_socket_toaddrinfo ( hostname, port, &addr_info_data );
3.86 -
3.87 - g_return_val_if_fail( addr_info_data != NULL, FALSE );
3.88 + gmyth_debug ( "[%s] Invalid hostname parameter!\n", __FUNCTION__ );
3.89
3.90 /* store hostname and port number */
3.91 if (gmyth_socket->hostname != NULL) {
3.92 @@ -515,6 +527,10 @@
3.93 gmyth_socket->hostname = NULL;
3.94 }
3.95
3.96 + errno = gmyth_socket_toaddrinfo ( hostname, port, &addr_info_data );
3.97 +
3.98 + g_return_val_if_fail( addr_info_data != NULL && hostname != NULL, FALSE );
3.99 +
3.100 gmyth_socket->hostname = g_strdup( hostname );
3.101 gmyth_socket->port = port;
3.102
3.103 @@ -740,7 +756,7 @@
3.104 g_string_free (result, TRUE);
3.105 }
3.106
3.107 - g_string_free (hostname, TRUE);
3.108 + g_string_free (hostname, FALSE);
3.109 g_string_free (base_str, TRUE);
3.110
3.111 return TRUE;
4.1 --- a/gmyth/src/gmyth_tvchain.c Mon Dec 18 22:19:58 2006 +0000
4.2 +++ b/gmyth/src/gmyth_tvchain.c Tue Dec 19 16:25:25 2006 +0000
4.3 @@ -196,9 +196,7 @@
4.4 if (!gmyth_query_connect (gmyth_query, tvchain->backend_info)) {
4.5 g_warning ("[%s] Could not connect to db", __FUNCTION__);
4.6 g_static_mutex_unlock( &mutex );
4.7 -
4.8 ret = FALSE;
4.9 -
4.10 goto done;
4.11 }
4.12
4.13 @@ -216,9 +214,9 @@
4.14 while ((msql_row = mysql_fetch_row (msql_res)) != NULL) {
4.15 struct LiveTVChainEntry *entry = g_new0 (struct LiveTVChainEntry, 1);
4.16 entry->chanid = g_string_new (msql_row[0]);
4.17 - entry->starttime = gmyth_util_string_to_time_val ( g_strdup( msql_row[1] ) );
4.18 - entry->endtime = gmyth_util_string_to_time_val ( g_strdup( msql_row[2] ) );
4.19 - entry->discontinuity = g_ascii_strtoull( msql_row[3], NULL, 10 ) != 0;
4.20 + entry->starttime = gmyth_util_string_to_time_val ((const gchar*) msql_row[1]);
4.21 + entry->endtime = gmyth_util_string_to_time_val ((const gchar*) msql_row[2]);
4.22 + entry->discontinuity = g_ascii_strtoull (msql_row[3], NULL, 10 ) != 0;
4.23 entry->hostprefix = g_string_new (msql_row[5]);
4.24 entry->cardtype = g_string_new (msql_row[6]);
4.25 entry->channum = g_string_new (msql_row[7]);
4.26 @@ -259,7 +257,7 @@
4.27
4.28 done:
4.29 if ( stmt_str != NULL )
4.30 - g_string_free (stmt_str, FALSE);
4.31 + g_string_free (stmt_str, TRUE);
4.32
4.33 if ( msql_res != NULL )
4.34 mysql_free_result (msql_res);