[svn r473] memory leek fix trunk
authorrenatofilho
Wed Mar 28 21:26:42 2007 +0100 (2007-03-28)
branchtrunk
changeset 468f4c6061f6f39
parent 467 bc13aaf7561d
child 469 28879368706b
[svn r473] memory leek fix
gmyth/src/gmyth_livetv.c
gmyth/src/gmyth_socket.c
gmyth/src/gmyth_util.c
     1.1 --- a/gmyth/src/gmyth_livetv.c	Wed Mar 28 15:53:29 2007 +0100
     1.2 +++ b/gmyth/src/gmyth_livetv.c	Wed Mar 28 21:26:42 2007 +0100
     1.3 @@ -470,7 +470,7 @@
     1.4  	
     1.5  		} /* if - changes the channel number */
     1.6  		
     1.7 -    //sleep (1);                  /* FIXME: this is evil (tpm) */
     1.8 +    sleep (5);                  /* FIXME: this is evil (tpm) */
     1.9    }
    1.10    
    1.11    /* DEBUG message */  
    1.12 @@ -549,12 +549,14 @@
    1.13  	
    1.14  	g_mutex_unlock( livetv->mutex );
    1.15  
    1.16 +/*
    1.17  	if ( !gmyth_livetv_monitor_handler_start( livetv ) )
    1.18  	{
    1.19  		res = FALSE;
    1.20  		gmyth_debug( "LiveTV MONITOR handler error on setup!" );
    1.21  		goto error;		
    1.22  	}
    1.23 +*/
    1.24  	
    1.25  	livetv->setup_done = TRUE;
    1.26  	
     2.1 --- a/gmyth/src/gmyth_socket.c	Wed Mar 28 15:53:29 2007 +0100
     2.2 +++ b/gmyth/src/gmyth_socket.c	Wed Mar 28 21:26:42 2007 +0100
     2.3 @@ -492,7 +492,7 @@
     2.4  	const gchar *hostname, gint port, guint timeout)
     2.5  {
     2.6      struct addrinfo *addr_info_data = NULL, *addr_info0 = NULL;
     2.7 -    struct linger* ling = NULL;
     2.8 +    struct linger ling;
     2.9      gchar *tmp_str;
    2.10      gint ret_code = 0; /* -1 */
    2.11      /* FIXME: add as function parameter */
    2.12 @@ -564,12 +564,13 @@
    2.13          g_io_channel_unref (gmyth_socket->sd_io_ch);
    2.14          gmyth_socket->sd_io_ch = NULL;
    2.15      }
    2.16 +   
    2.17 +    	 
    2.18 +    memset (&ling, 0, sizeof (struct linger));
    2.19 +    ling.l_onoff = TRUE;
    2.20 +    ling.l_linger = 1;
    2.21      
    2.22 -    ling = g_malloc0( sizeof(struct linger) );
    2.23 -    ling->l_onoff = TRUE;
    2.24 -    ling->l_linger = 1;
    2.25 -    
    2.26 -    err = setsockopt(gmyth_socket->sd, SOL_SOCKET, SO_LINGER, ling, sizeof(struct linger));
    2.27 +    err = setsockopt(gmyth_socket->sd, SOL_SOCKET, SO_LINGER, &ling, sizeof(struct linger));
    2.28  	  
    2.29      if( err < 0 ) {
    2.30          gmyth_debug( "[%s] Setting connection unsucessfull.\n", __FUNCTION__ );
    2.31 @@ -593,9 +594,6 @@
    2.32      ret = ( ret_code == 0 ) ? TRUE : FALSE ;
    2.33  
    2.34  cleanup:
    2.35 -    if ( !ling )
    2.36 -        g_free (ling);
    2.37 -    
    2.38      if ( !ret )
    2.39      	gmyth_debug("GMythSocket error - return code error!");
    2.40      	
    2.41 @@ -1111,7 +1109,7 @@
    2.42      g_free (str_array);
    2.43  
    2.44      /* ptr_array is pointing to data inside str_list->glist */
    2.45 -    g_ptr_array_free (ptr_array, FALSE);
    2.46 +    g_ptr_array_free (ptr_array, TRUE);
    2.47  
    2.48      return TRUE;
    2.49  }
     3.1 --- a/gmyth/src/gmyth_util.c	Wed Mar 28 15:53:29 2007 +0100
     3.2 +++ b/gmyth/src/gmyth_util.c	Wed Mar 28 21:26:42 2007 +0100
     3.3 @@ -122,19 +122,19 @@
     3.4  	
     3.5  	if ( NULL == localtime_r( &time, tm_time ) ) {
     3.6  		g_warning ("gmyth_util_time_to_isoformat convertion error!\n");
     3.7 -    } else {
     3.8 -        /* we first check the return of strftime to allocate a buffer of the correct size */
     3.9 -        buffer_len = strftime( NULL, SSIZE_MAX, fmt_string, tm_time );
    3.10 -        if ( buffer_len > 0 ) {
    3.11 -            result = g_malloc0( buffer_len + 1 );
    3.12 -            if( result == NULL ) {
    3.13 -                g_static_mutex_unlock ( &mutex );
    3.14 -                g_warning ("gmyth_util_time_to_isoformat convertion error!\n");
    3.15 -                return NULL;
    3.16 -            }
    3.17 -            strftime( result, buffer_len + 1, fmt_string, tm_time );
    3.18 -            gmyth_debug( "Dateline (ISO result): %s", result );
    3.19 -        }
    3.20 +	} else {
    3.21 +		/* we first check the return of strftime to allocate a buffer of the correct size */
    3.22 +        	buffer_len = strftime( NULL, SSIZE_MAX, fmt_string, tm_time );
    3.23 +        	if ( buffer_len > 0 ) {
    3.24 +            		result = g_malloc0( buffer_len + 1 );
    3.25 +			if( result == NULL ) {
    3.26 +                		g_static_mutex_unlock ( &mutex );
    3.27 +                		g_warning ("gmyth_util_time_to_isoformat convertion error!\n");
    3.28 +                		return NULL;
    3.29 +            		}
    3.30 +            		strftime( result, buffer_len + 1, fmt_string, tm_time );
    3.31 +            		gmyth_debug( "Dateline (ISO result): %s", result );
    3.32 +        	}
    3.33  	} /* if */
    3.34  	
    3.35  	gmyth_debug( "Result (strftime) = %s", result );
    3.36 @@ -143,7 +143,7 @@
    3.37  	
    3.38  	//strftime( result, strlen(result), fmt_string, tm_time );
    3.39  	
    3.40 -    g_free (tm_time);
    3.41 +	g_free (tm_time);
    3.42  
    3.43  	g_static_mutex_unlock ( &mutex );
    3.44  	
    3.45 @@ -377,6 +377,7 @@
    3.46      gmyth_debug( "After mktime call... = %s", asctime(tm_time) );
    3.47      
    3.48      g_static_mutex_unlock ( &mutex );
    3.49 +    g_free (tm_time);
    3.50      
    3.51      return time;
    3.52  }