]> Dogcows Code - chaz/tint2/blobdiff - src/clock/clock.c
fixed memleak
[chaz/tint2] / src / clock / clock.c
index d020c5269fb33109494cd6a412d311d3fe238720..af7afe1e236740df361bb1790c07e31edee7d92a 100644 (file)
@@ -22,8 +22,6 @@
 #include <cairo.h>
 #include <cairo-xlib.h>
 #include <pango/pangocairo.h>
-#include <unistd.h>
-#include <signal.h>
 #include <stdlib.h>
 
 #include "window.h"
 #include "taskbar.h"
 #include "clock.h"
 #include "timer.h"
+#include "common.h"
 
 
-char *time1_format=0;
-char *time1_timezone=0;
-char *time2_format=0;
-char *time2_timezone=0;
-char *time_tooltip_format=0;
-char *time_tooltip_timezone=0;
-char *clock_lclick_command=0;
-char *clock_rclick_command=0;
+char *time1_format;
+char *time1_timezone;
+char *time2_format;
+char *time2_timezone;
+char *time_tooltip_format;
+char *time_tooltip_timezone;
+char *clock_lclick_command;
+char *clock_rclick_command;
 struct timeval time_clock;
-PangoFontDescription *time1_font_desc=0;
-PangoFontDescription *time2_font_desc=0;
+PangoFontDescription *time1_font_desc;
+PangoFontDescription *time2_font_desc;
 static char buf_time[40];
 static char buf_date[40];
 static char buf_tooltip[40];
 int clock_enabled;
-static timeout* clock_timeout=0;
+static timeout* clock_timeout;
+
+
+void default_clock()
+{
+       clock_enabled = 0;
+       clock_timeout = 0;
+       time1_format = 0;
+       time1_timezone = 0;
+       time2_format = 0;
+       time2_timezone = 0;
+       time_tooltip_format = 0;
+       time_tooltip_timezone = 0;
+       clock_lclick_command = 0;
+       clock_rclick_command = 0;
+       time1_font_desc = 0;
+       time2_font_desc = 0;
+}
+
+void cleanup_clock()
+{
+       if (time1_font_desc) pango_font_description_free(time1_font_desc);
+       if (time2_font_desc) pango_font_description_free(time2_font_desc);
+       if (time1_format) g_free(time1_format);
+       if (time2_format) g_free(time2_format);
+       if (time_tooltip_format) g_free(time_tooltip_format);
+       if (time1_timezone) g_free(time1_timezone);
+       if (time2_timezone) g_free(time2_timezone);
+       if (time_tooltip_timezone) g_free(time_tooltip_timezone);
+       if (clock_lclick_command) g_free(clock_lclick_command);
+       if (clock_rclick_command) g_free(clock_rclick_command);
+}
 
 
 void update_clocks_sec(void* arg)
@@ -160,52 +190,6 @@ void init_clock_panel(void *p)
 }
 
 
-void cleanup_clock()
-{
-       clock_enabled = 0;
-       if (time1_font_desc) {
-               pango_font_description_free(time1_font_desc);
-               time1_font_desc = 0;
-       }
-       if (time2_font_desc) {
-               pango_font_description_free(time2_font_desc);
-               time2_font_desc = 0;
-       }
-       if (time1_format) {
-               g_free(time1_format);
-               time1_format = 0;
-       }
-       if (time2_format) {
-               g_free(time2_format);
-               time2_format = 0;
-       }
-       if (time_tooltip_format) {
-               g_free(time_tooltip_format);
-               time_tooltip_format = 0;
-       }
-       if (time1_timezone) {
-               g_free(time1_timezone);
-               time1_timezone = 0;
-       }
-       if (time2_timezone) {
-               g_free(time2_timezone);
-               time2_timezone = 0;
-       }
-       if (time_tooltip_timezone) {
-               g_free(time_tooltip_timezone);
-               time_tooltip_timezone = 0;
-       }
-       if (clock_lclick_command) {
-               g_free(clock_lclick_command);
-               clock_lclick_command = 0;
-       }
-       if (clock_rclick_command) {
-               g_free(clock_rclick_command);
-               clock_rclick_command = 0;
-       }
-}
-
-
 void draw_clock (void *obj, cairo_t *c)
 {
        Clock *clock = obj;
@@ -317,17 +301,6 @@ void clock_action(int button)
                command = clock_rclick_command;
                break;
        }
-       if (command) {
-               pid_t pid;
-               pid = fork();
-               if (pid == 0) {
-                       // change for the fork the signal mask
-//                     sigset_t sigset;
-//                     sigprocmask(SIG_SETMASK, &sigset, 0);
-//                     sigprocmask(SIG_UNBLOCK, &sigset, 0);
-                       execl("/bin/sh", "/bin/sh", "-c", command, NULL);
-                       _exit(0);
-               }
-       }
+       tint_exec(command);
 }
 
This page took 0.024 seconds and 4 git commands to generate.