fix minor memleak when closing conky
authorNikolas Garofil <garo@dunaldi.garofil.be>
Tue, 7 Jul 2009 15:27:57 +0000 (17:27 +0200)
committerNikolas Garofil <garo@dunaldi.garofil.be>
Tue, 7 Jul 2009 15:27:57 +0000 (17:27 +0200)
src/conky.c
src/linux.c

index bf0662e..dd8bb50 100644 (file)
@@ -146,6 +146,7 @@ enum x_initialiser_state x_initialised = NO;
 static volatile int g_signal_pending;
 /* Update interval */
 double update_interval;
+void *global_cpu = NULL;
 
 
 /* prototypes for internally used functions */
@@ -7609,6 +7610,7 @@ static void clean_up(void)
        }
 
        clear_diskio_stats();
+       if(global_cpu != NULL) free(global_cpu);
 }
 
 static int string_to_bool(const char *s)
index d03d0de..af10179 100644 (file)
@@ -617,6 +617,7 @@ inline static void update_stat(void)
        double curtmp;
        const char *stat_template = NULL;
        unsigned int malloc_cpu_size = 0;
+       extern void* global_cpu;
 
        /* add check for !info.cpu_usage since that mem is freed on a SIGUSR1 */
        if (!cpu_setup || !info.cpu_usage) {
@@ -633,6 +634,7 @@ inline static void update_stat(void)
                malloc_cpu_size = (info.cpu_count + 1) * sizeof(struct cpu_info);
                cpu = malloc(malloc_cpu_size);
                memset(cpu, 0, malloc_cpu_size);
+               global_cpu = cpu;
        }
 
        if (!(stat_fp = open_file("/proc/stat", &rep))) {