[Xfce4-commits] <xfce4-cpugraph-plugin:master> Plug a small memory leak

Florian noreply at xfce.org
Sat Apr 17 16:16:05 CEST 2010


Updating branch refs/heads/master
         to c377173807992a57510f22e4e2c7213f4ce6e504 (commit)
       from 32f2075c5de9a02dd796497b024d14d28916f958 (commit)

commit c377173807992a57510f22e4e2c7213f4ce6e504
Author: Florian Rivoal <frivoal at gmail.com>
Date:   Sun Feb 7 02:35:11 2010 +0900

    Plug a small memory leak
    
    Changing the command run when clicking on the CPU graph would leak a
    little amount of memory. The same object wasn't properly clean up at
    shutdown time either.

 panel-plugin/cpu.c |   14 ++++++++++++--
 panel-plugin/cpu.h |    2 ++
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/panel-plugin/cpu.c b/panel-plugin/cpu.c
index c933aff..377c5dd 100644
--- a/panel-plugin/cpu.c
+++ b/panel-plugin/cpu.c
@@ -51,6 +51,7 @@ void Kill( XfcePanelPlugin * plugin, CPUGraph * base )
 
 	g_object_unref( base->m_Tooltip );
 
+	g_free( base->m_AssociateCommand );
 	g_free( base );
 }
 
@@ -81,7 +82,7 @@ void ReadSettings( XfcePanelPlugin * plugin, CPUGraph * base )
 
 	base->m_TimeScale = 0;
 	base->m_Frame = 0;
-	base->m_AssociateCommand = "xterm top";
+	base->m_AssociateCommand = NULL;
 	base->m_ColorMode = 0;
 	base->m_Mode = 0;
 
@@ -108,9 +109,13 @@ void ReadSettings( XfcePanelPlugin * plugin, CPUGraph * base )
 			base->m_Frame =
 				xfce_rc_read_int_entry( rc, "Frame", base->m_Frame );
 
-			if( value = xfce_rc_read_entry( rc, "AssociateCommand", base->m_AssociateCommand ) ) {
+			if( value = xfce_rc_read_entry( rc, "AssociateCommand", DEFAULT_COMMAND ) ) {
 				base->m_AssociateCommand = g_strdup(value);
 			}
+			else
+			{
+				base->m_AssociateCommand = g_strdup( DEFAULT_COMMAND );
+			}
 
 			base->m_ColorMode =
 				xfce_rc_read_int_entry( rc, "ColorMode", base->m_ColorMode );
@@ -135,6 +140,10 @@ void ReadSettings( XfcePanelPlugin * plugin, CPUGraph * base )
 			xfce_rc_close( rc );
 		}
 	}
+	else
+	{
+		base->m_AssociateCommand = g_strdup( DEFAULT_COMMAND );
+	}
 	SetHistorySize( base, base->m_Width );
 	if( base->m_TimeoutID )
 		g_source_remove( base->m_TimeoutID );
@@ -947,6 +956,7 @@ void FrameChange( GtkToggleButton * button, CPUGraph * base )
 
 void AssociateCommandChange( GtkEntry *entry, CPUGraph * base )
 {
+	g_free (base->m_AssociateCommand );
 	base->m_AssociateCommand = g_strdup( gtk_entry_get_text( entry ) );
 }
 
diff --git a/panel-plugin/cpu.h b/panel-plugin/cpu.h
index d8e4fe1..1a9580d 100644
--- a/panel-plugin/cpu.h
+++ b/panel-plugin/cpu.h
@@ -18,6 +18,8 @@
 
 #include "os.h"
 
+#define DEFAULT_COMMAND "xterm top"
+
 #define BORDER  8
 
 #define MAX_WIDTH 64



More information about the Xfce4-commits mailing list