all repos — tint2 @ af003d0e198de4bbcf9f066287dfbf26c179a4da

fork of the tint2 desktop panel for my custom setup - only minimized windows across all desktops for the taskbar

Memory management review: match char-malloc/strdup-free, gchar-g_str*/g_free; set pointers to null after free; initialize fonts/backgrounds correctly when missing from config

git-svn-id: http://tint2.googlecode.com/svn/trunk@748 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
o9000 o9000
commit

af003d0e198de4bbcf9f066287dfbf26c179a4da

parent

321ccc07944901895ad4964324b915294280a797

M src/battery/battery.csrc/battery/battery.c

@@ -56,10 +56,10 @@

int8_t battery_low_status; unsigned char battery_low_cmd_sent; char *battery_low_cmd; -char *path_energy_now; -char *path_energy_full; -char *path_current_now; -char *path_status; +gchar *path_energy_now; +gchar *path_energy_full; +gchar *path_current_now; +gchar *path_status; int battery_found; #if defined(__OpenBSD__) || defined(__NetBSD__)

@@ -126,17 +126,19 @@ battery_enabled = 0;

battery_found = 0; percentage_hide = 101; battery_low_cmd_sent = 0; - battery_timeout = 0; - bat1_font_desc = 0; - bat2_font_desc = 0; - battery_low_cmd = 0; - path_energy_now = 0; - path_energy_full = 0; - path_current_now = 0; - path_status = 0; + battery_timeout = NULL; + bat1_font_desc = NULL; + bat2_font_desc = NULL; + battery_low_cmd = NULL; + path_energy_now = NULL; + path_energy_full = NULL; + path_current_now = NULL; + path_status = NULL; battery_state.percentage = 0; battery_state.time.hours = 0; battery_state.time.minutes = 0; + battery_state.time.seconds = 0; + battery_state.state = BATTERY_UNKNOWN; #if defined(__OpenBSD__) || defined(__NetBSD__) apm_fd = -1; #endif

@@ -145,21 +147,21 @@

void cleanup_battery() { pango_font_description_free(bat1_font_desc); - bat1_font_desc = 0; + bat1_font_desc = NULL; pango_font_description_free(bat2_font_desc); - bat2_font_desc = 0; + bat2_font_desc = NULL; g_free(path_energy_now); - path_energy_now = 0; + path_energy_now = NULL; g_free(path_energy_full); - path_energy_full = 0; + path_energy_full = NULL; g_free(path_current_now); - path_current_now = 0; + path_current_now = NULL; g_free(path_status); - path_status = 0; - g_free(battery_low_cmd); - battery_low_cmd = 0; + path_status = NULL; + free(battery_low_cmd); + battery_low_cmd = NULL; stop_timeout(battery_timeout); - battery_timeout = 0; + battery_timeout = NULL; battery_found = 0; #if defined(__OpenBSD__) || defined(__NetBSD__)

@@ -191,7 +193,7 @@ #else // Linux

GDir *directory = 0; GError *error = NULL; const char *entryname; - char *battery_dir = 0; + gchar *battery_dir = 0; directory = g_dir_open("/sys/class/power_supply", 0, &error); if (error) {

@@ -285,6 +287,11 @@ Battery *battery = &panel->battery;

if (!battery_enabled) return; + + if (!bat1_font_desc) + bat1_font_desc = pango_font_description_from_string(DEFAULT_FONT); + if (!bat2_font_desc) + bat2_font_desc = pango_font_description_from_string(DEFAULT_FONT); if (battery->area.bg == 0) battery->area.bg = &g_array_index(backgrounds, Background, 0);
M src/clock/clock.csrc/clock/clock.c

@@ -53,32 +53,43 @@

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; + clock_timeout = NULL; + time1_format = NULL; + time1_timezone = NULL; + time2_format = NULL; + time2_timezone = NULL; + time_tooltip_format = NULL; + time_tooltip_timezone = NULL; + clock_lclick_command = NULL; + clock_rclick_command = NULL; + time1_font_desc = NULL; + time2_font_desc = NULL; } 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); - if (clock_timeout) stop_timeout(clock_timeout); + pango_font_description_free(time1_font_desc); + time1_font_desc = NULL; + pango_font_description_free(time2_font_desc); + time2_font_desc = NULL; + free(time1_format); + time1_format = NULL; + free(time2_format); + time2_format = NULL; + free(time_tooltip_format); + time_tooltip_format = NULL; + free(time1_timezone); + time1_timezone = NULL; + free(time2_timezone); + time2_timezone = NULL; + free(time_tooltip_timezone); + time_tooltip_timezone = NULL; + free(clock_lclick_command); + clock_lclick_command = NULL; + free(clock_rclick_command); + clock_rclick_command = NULL; + stop_timeout(clock_timeout); + clock_timeout = NULL; }

@@ -138,7 +149,7 @@ }

void init_clock() { - if (clock_timeout == 0) { + if (!clock_timeout) { if (time_format_needs_sec_ticks(time1_format) || time_format_needs_sec_ticks(time2_format)) { clock_timeout = add_timeout(10, 1000, update_clocks_sec, 0);

@@ -154,7 +165,11 @@ {

Panel *panel =(Panel*)p; Clock *clock = &panel->clock; - if (clock->area.bg == 0) + if (!time1_font_desc) + time1_font_desc = pango_font_description_from_string(DEFAULT_FONT); + if (!time2_font_desc) + time2_font_desc = pango_font_description_from_string(DEFAULT_FONT); + if (!clock->area.bg) clock->area.bg = &g_array_index(backgrounds, Background, 0); clock->area.parent = p; clock->area.panel = p;

@@ -162,7 +177,7 @@ clock->area._draw_foreground = draw_clock;

clock->area.size_mode = SIZE_BY_CONTENT; clock->area._resize = resize_clock; // check consistency - if (time1_format == 0) + if (!time1_format) return; clock->area.resize = 1;
M src/config.csrc/config.c

@@ -72,15 +72,17 @@

void default_config() { - config_path = 0; - snapshot_path = 0; + config_path = NULL; + snapshot_path = NULL; new_config_file = 0; } void cleanup_config() { - if (config_path) g_free(config_path); - if (snapshot_path) g_free(snapshot_path); + free(config_path); + config_path = NULL; + free(snapshot_path); + snapshot_path = NULL; }

@@ -158,7 +160,7 @@ while ((name = g_dir_read_name(d))) {

gchar *file = g_build_filename(path, name, NULL); if (!g_file_test(file, G_FILE_TEST_IS_DIR) && g_str_has_suffix(file, ".desktop")) { - panel_config.launcher.list_apps = g_slist_append(panel_config.launcher.list_apps, (char *)strdup(file)); + panel_config.launcher.list_apps = g_slist_append(panel_config.launcher.list_apps, strdup(file)); } else if (g_file_test(file, G_FILE_TEST_IS_DIR)) { load_launcher_app_dir(file); }

@@ -373,12 +375,13 @@ else if (strcmp (key, "time1_format") == 0) {

if (new_config_file == 0) { clock_enabled = 1; if (panel_items_order) { - char* tmp = g_strconcat(panel_items_order, "C", NULL); - g_free( panel_items_order ); - panel_items_order = tmp; + gchar* tmp = g_strconcat(panel_items_order, "C", NULL); + free(panel_items_order); + panel_items_order = strdup(tmp); + g_free(tmp); } else - panel_items_order = g_strdup("C"); + panel_items_order = strdup("C"); } if (strlen(value) > 0) { time1_format = strdup (value);

@@ -581,12 +584,13 @@ else if (strcmp (key, "systray_padding") == 0) {

if (new_config_file == 0 && systray_enabled == 0) { systray_enabled = 1; if (panel_items_order) { - char* tmp = g_strconcat(panel_items_order, "S", NULL); - g_free( panel_items_order ); - panel_items_order = tmp; + gchar* tmp = g_strconcat(panel_items_order, "S", NULL); + free(panel_items_order); + panel_items_order = strdup(tmp); + g_free(tmp); } else - panel_items_order = g_strdup("S"); + panel_items_order = strdup("S"); } extract_values(value, &value1, &value2, &value3); systray.area.paddingxlr = systray.area.paddingx = atoi (value1);

@@ -734,12 +738,13 @@ if (new_config_file == 0) {

systray_enabled = atoi(value); if (systray_enabled) { if (panel_items_order) { - char* tmp = g_strconcat(panel_items_order, "S", NULL); - g_free( panel_items_order ); - panel_items_order = tmp; + gchar* tmp = g_strconcat(panel_items_order, "S", NULL); + free(panel_items_order); + panel_items_order = strdup(tmp); + g_free(tmp); } else - panel_items_order = g_strdup("S"); + panel_items_order = strdup("S"); } } }

@@ -749,12 +754,13 @@ if (new_config_file == 0) {

battery_enabled = atoi(value); if (battery_enabled) { if (panel_items_order) { - char* tmp = g_strconcat(panel_items_order, "B", NULL); - g_free( panel_items_order ); - panel_items_order = tmp; + gchar* tmp = g_strconcat(panel_items_order, "B", NULL); + free(panel_items_order); + panel_items_order = strdup(tmp); + g_free(tmp); } else - panel_items_order = g_strdup("B"); + panel_items_order = strdup("B"); } } }

@@ -771,7 +777,7 @@

int config_read () { const gchar * const * system_dirs; - char *path1; + gchar *path1; gint i; // follow XDG specification

@@ -786,19 +792,19 @@ }

g_free(path1); // copy tint2rc from system directory to user directory - char *path2 = 0; + gchar *path2 = 0; system_dirs = g_get_system_config_dirs(); for (i = 0; system_dirs[i]; i++) { path2 = g_build_filename(system_dirs[i], "tint2", "tint2rc", NULL); if (g_file_test(path2, G_FILE_TEST_EXISTS)) break; - g_free (path2); + g_free(path2); path2 = 0; } if (path2) { // copy file in user directory (path1) - char *dir = g_build_filename (g_get_user_config_dir(), "tint2", NULL); + gchar *dir = g_build_filename (g_get_user_config_dir(), "tint2", NULL); if (!g_file_test (dir, G_FILE_TEST_IS_DIR)) g_mkdir(dir, 0777); g_free(dir);

@@ -836,12 +842,13 @@ // append Taskbar item

if (new_config_file == 0) { taskbar_enabled = 1; if (panel_items_order) { - char* tmp = g_strconcat( "T", panel_items_order, NULL ); - g_free(panel_items_order); - panel_items_order = tmp; + gchar* tmp = g_strconcat("T", panel_items_order, NULL); + free(panel_items_order); + panel_items_order = strdup(tmp); + g_free(tmp); } else - panel_items_order = g_strdup("T"); + panel_items_order = strdup("T"); } return 1;
M src/launcher/icon-theme-common.csrc/launcher/icon-theme-common.c

@@ -228,7 +228,7 @@ }

IconTheme *load_theme_from_fs(char *name, IconTheme *theme) { - char *dir_name = NULL; + gchar *dir_name = NULL; const GSList *location; for (location = get_icon_locations(); location; location = g_slist_next(location)) { gchar *path = (gchar*) location->data;

@@ -255,7 +255,7 @@

if (name == NULL) return NULL; - char *file_name = NULL; + gchar *file_name = NULL; const GSList *location; for (location = get_icon_locations(); location; location = g_slist_next(location)) { gchar *path = (gchar*) location->data;
M src/launcher/launcher.csrc/launcher/launcher.c

@@ -96,7 +96,7 @@ launcher->area.size_mode = SIZE_BY_CONTENT;

launcher->area._resize = resize_launcher; launcher->area.resize = 1; launcher->area.redraw = 1; - if (launcher->area.bg == 0) + if (!launcher->area.bg) launcher->area.bg = &g_array_index(backgrounds, Background, 0); // check consistency

@@ -118,20 +118,26 @@ GSList *l;

if (xsettings_client) xsettings_client_destroy(xsettings_client); - for (i = 0 ; i < nb_panel ; i++) { + xsettings_client = NULL; + + for (i = 0; i < nb_panel; i++) { Panel *panel = &panel1[i]; Launcher *launcher = &panel->launcher; cleanup_launcher_theme(launcher); } + for (l = panel_config.launcher.list_apps; l ; l = l->next) { free(l->data); } g_slist_free(panel_config.launcher.list_apps); panel_config.launcher.list_apps = NULL; + free(icon_theme_name_config); icon_theme_name_config = NULL; + free(icon_theme_name_xsettings); icon_theme_name_xsettings = NULL; + launcher_enabled = 0; }

@@ -153,9 +159,9 @@ }

free(launcherIcon); } g_slist_free(launcher->list_icons); + launcher->list_icons = NULL; free_themes(launcher->list_themes); - launcher->list_icons = NULL; launcher->list_themes = NULL; }
M src/panel.csrc/panel.c

@@ -82,7 +82,7 @@ default_icon = NULL;

task_dragged = 0; panel_horizontal = 1; panel_position = CENTER; - panel_items_order = 0; + panel_items_order = NULL; panel_autohide = 0; panel_autohide_show_timeout = 0; panel_autohide_hide_timeout = 0;

@@ -106,29 +106,39 @@ }

void cleanup_panel() { - if (!panel1) return; + if (!panel1) + return; cleanup_taskbar(); - // taskbarname_font_desc freed here because cleanup_taskbarname() called on _NET_NUMBER_OF_DESKTOPS - if (taskbarname_font_desc) pango_font_description_free(taskbarname_font_desc); int i; Panel *p; - for (i=0 ; i < nb_panel ; i++) { + for (i = 0; i < nb_panel; i++) { p = &panel1[i]; free_area(&p->area); - if (p->temp_pmap) XFreePixmap(server.dsp, p->temp_pmap); - if (p->hidden_pixmap) XFreePixmap(server.dsp, p->hidden_pixmap); - if (p->main_win) XDestroyWindow(server.dsp, p->main_win); + if (p->temp_pmap) + XFreePixmap(server.dsp, p->temp_pmap); + p->temp_pmap = 0; + if (p->hidden_pixmap) + XFreePixmap(server.dsp, p->hidden_pixmap); + p->hidden_pixmap = 0; + if (p->main_win) + XDestroyWindow(server.dsp, p->main_win); + p->main_win = 0; } - if (panel_items_order) g_free(panel_items_order); + free(panel_items_order); + panel_items_order = NULL; free(panel_window_name); - if (panel1) free(panel1); + panel_window_name = NULL; + free(panel1); + panel1 = NULL; if (backgrounds) g_array_free(backgrounds, 1); - if (panel_config.g_task.font_desc) pango_font_description_free(panel_config.g_task.font_desc); + backgrounds = NULL; + pango_font_description_free(panel_config.g_task.font_desc); + panel_config.g_task.font_desc = NULL; } void init_panel()

@@ -168,7 +178,7 @@ p = &panel1[i];

if (panel_config.monitor < 0) p->monitor = i; - if ( p->area.bg == 0 ) + if (!p->area.bg) p->area.bg = &g_array_index(backgrounds, Background, 0); p->area.parent = p; p->area.panel = p;
M src/panel.hsrc/panel.h

@@ -68,6 +68,8 @@

extern GArray* backgrounds; extern Imlib_Image default_icon; +// TODO maybe this should be a config option +#define DEFAULT_FONT "sans 10" // tint2 use one panel per monitor and one taskbar per desktop.
M src/server.csrc/server.c

@@ -83,7 +83,7 @@ server.atom.WM_NAME = XInternAtom(server.dsp, "WM_NAME", False);

server.atom.__SWM_VROOT = XInternAtom(server.dsp, "__SWM_VROOT", False); server.atom._MOTIF_WM_HINTS = XInternAtom(server.dsp, "_MOTIF_WM_HINTS", False); server.atom.WM_HINTS = XInternAtom(server.dsp, "WM_HINTS", False); - char *name = g_strdup_printf("_XSETTINGS_S%d", DefaultScreen(server.dsp)); + gchar *name = g_strdup_printf("_XSETTINGS_S%d", DefaultScreen(server.dsp)); server.atom._XSETTINGS_SCREEN = XInternAtom(server.dsp, name, False); g_free(name); server.atom._XSETTINGS_SETTINGS = XInternAtom(server.dsp, "_XSETTINGS_SETTINGS", False);

@@ -116,16 +116,24 @@

void cleanup_server() { - if (server.colormap) XFreeColormap(server.dsp, server.colormap); - if (server.colormap32) XFreeColormap(server.dsp, server.colormap32); + if (server.colormap) + XFreeColormap(server.dsp, server.colormap); + server.colormap = 0; + if (server.colormap32) + XFreeColormap(server.dsp, server.colormap32); + server.colormap32 = 0; if (server.monitor) { int i; - for (i=0; i<server.nb_monitor; ++i) - if (server.monitor[i].names) - g_strfreev(server.monitor[i].names); + for (i = 0; i < server.nb_monitor; ++i) { + g_strfreev(server.monitor[i].names); + server.monitor[i].names = NULL; + } free(server.monitor); + server.monitor = NULL; } - if (server.gc) XFreeGC(server.dsp, server.gc); + if (server.gc) + XFreeGC(server.dsp, server.gc); + server.gc = NULL; server.disable_transparency = 0; }

@@ -294,7 +302,7 @@ server.monitor[i].x = crtc_info->x;

server.monitor[i].y = crtc_info->y; server.monitor[i].width = crtc_info->width; server.monitor[i].height = crtc_info->height; - server.monitor[i].names = malloc((crtc_info->noutput+1) * sizeof(char*)); + server.monitor[i].names = malloc((crtc_info->noutput+1) * sizeof(gchar*)); for (j=0; j<crtc_info->noutput; ++j) { XRROutputInfo* output_info = XRRGetOutputInfo(server.dsp, res, crtc_info->outputs[j]); printf("xRandr: Linking output %s with crtc %d\n", output_info->name, i);
M src/server.hsrc/server.h

@@ -97,7 +97,7 @@ int x;

int y; int width; int height; - char** names; + gchar** names; } Monitor;
M src/systray/systraybar.csrc/systray/systraybar.c

@@ -100,7 +100,7 @@ void init_systray_panel(void *p)

{ systray.area.parent = p; systray.area.panel = p; - if (systray.area.bg == 0) + if (!systray.area.bg) systray.area.bg = &g_array_index(backgrounds, Background, 0); GSList *l;

@@ -308,7 +308,7 @@ while(systray.list_icons)

remove_icon((TrayWindow*)systray.list_icons->data); g_slist_free(systray.list_icons); - systray.list_icons = 0; + systray.list_icons = NULL; } if (net_sel_win != None) {

@@ -501,7 +501,7 @@

// check empty systray int count = 0; GSList *l; - for (l = systray.list_icons; l ; l = l->next) { + for (l = systray.list_icons; l; l = l->next) { if (!((TrayWindow*)l->data)->hide) count++; }
M src/taskbar/task.csrc/taskbar/task.c

@@ -618,7 +618,7 @@

// not yet in the list, so we have to add it urgent_list = g_slist_prepend(urgent_list, tsk); - if (urgent_timeout == 0) + if (!urgent_timeout) urgent_timeout = add_timeout(10, 1000, blink_urgent, 0); Panel *panel = tsk->area.panel;

@@ -630,8 +630,8 @@

void del_urgent(Task *tsk) { urgent_list = g_slist_remove(urgent_list, tsk); - if (urgent_list == 0) { + if (!urgent_list) { stop_timeout(urgent_timeout); - urgent_timeout = 0; + urgent_timeout = NULL; } }
M src/taskbar/taskbar.csrc/taskbar/taskbar.c

@@ -55,9 +55,9 @@

void default_taskbar() { - win_to_task_table = 0; - urgent_timeout = 0; - urgent_list = 0; + win_to_task_table = NULL; + urgent_timeout = NULL; + urgent_list = NULL; taskbar_enabled = 0; taskbar_distribute_size = 0; hide_inactive_tasks = 0;

@@ -78,33 +78,38 @@ while (g_hash_table_size(win_to_task_table)) {

GHashTableIter iter; gpointer key, value; - g_hash_table_iter_init (&iter, win_to_task_table); - if (g_hash_table_iter_next (&iter, &key, &value)) { + g_hash_table_iter_init(&iter, win_to_task_table); + if (g_hash_table_iter_next(&iter, &key, &value)) { taskbar_remove_task(key, 0, 0); } } + g_hash_table_destroy(win_to_task_table); + win_to_task_table = NULL; } - for (i=0 ; i < nb_panel ; i++) { + for (i = 0 ; i < nb_panel; i++) { panel = &panel1[i]; - for (j=0 ; j < panel->nb_desktop ; j++) { + for (j = 0; j < panel->nb_desktop; j++) { tskbar = &panel->taskbar[j]; - for (k=0; k<TASKBAR_STATE_COUNT; ++k) { - if (tskbar->state_pix[k]) XFreePixmap(server.dsp, tskbar->state_pix[k]); + for (k = 0; k < TASKBAR_STATE_COUNT; ++k) { + if (tskbar->state_pix[k]) + XFreePixmap(server.dsp, tskbar->state_pix[k]); + tskbar->state_pix[k] = 0; } - free_area (&tskbar->area); + free_area(&tskbar->area); // remove taskbar from the panel panel->area.list = g_slist_remove(panel->area.list, tskbar); } if (panel->taskbar) { free(panel->taskbar); - panel->taskbar = 0; + panel->taskbar = NULL; } } - if (win_to_task_table) { - g_hash_table_destroy(win_to_task_table); - win_to_task_table = 0; - } + g_slist_free(urgent_list); + urgent_list = NULL; + + stop_timeout(urgent_timeout); + urgent_timeout = NULL; }

@@ -131,6 +136,8 @@ if (panel->g_taskbar.background_name[TASKBAR_NORMAL] == 0) {

panel->g_taskbar.background_name[TASKBAR_NORMAL] = &g_array_index(backgrounds, Background, 0); panel->g_taskbar.background_name[TASKBAR_ACTIVE] = &g_array_index(backgrounds, Background, 0); } + if (!panel->g_task.font_desc) + panel->g_task.font_desc = pango_font_description_from_string(DEFAULT_FONT); if (panel->g_task.area.bg == 0) panel->g_task.area.bg = &g_array_index(backgrounds, Background, 0);
M src/taskbar/taskbar.hsrc/taskbar/taskbar.h

@@ -12,7 +12,7 @@ #include "task.h"

#include "taskbarname.h" enum { TASKBAR_NORMAL, TASKBAR_ACTIVE, TASKBAR_STATE_COUNT }; -extern GHashTable* win_to_task_table; +extern GHashTable *win_to_task_table; extern Task *task_active; extern Task *task_drag; extern int taskbar_enabled;

@@ -27,7 +27,7 @@ // always start with area

Area area; Pixmap state_pix[TASKBAR_STATE_COUNT]; - char *name; + gchar *name; int posy; } Taskbarname;
M src/taskbar/taskbarname.csrc/taskbar/taskbarname.c

@@ -41,7 +41,7 @@

void default_taskbarname() { taskbarname_enabled = 0; - taskbarname_font_desc = 0; + taskbarname_font_desc = NULL; }

@@ -51,7 +51,11 @@ Panel *panel =(Panel*)p;

Taskbar *tskbar; int j; - if (!taskbarname_enabled) return; + if (!taskbarname_enabled) + return; + + if (!taskbarname_font_desc) + taskbarname_font_desc = pango_font_description_from_string(DEFAULT_FONT); GSList *l, *list = server_get_name_of_desktop(); for (j=0, l=list ; j < panel->nb_desktop ; j++) {

@@ -87,18 +91,24 @@ int i, j, k;

Panel *panel; Taskbar *tskbar; - for (i=0 ; i < nb_panel ; i++) { + for (i = 0; i < nb_panel; i++) { panel = &panel1[i]; - for (j=0 ; j < panel->nb_desktop ; j++) { + for (j = 0; j < panel->nb_desktop; j++) { tskbar = &panel->taskbar[j]; - if (tskbar->bar_name.name) g_free(tskbar->bar_name.name); - free_area (&tskbar->bar_name.area); - for (k=0; k<TASKBAR_STATE_COUNT; ++k) { - if (tskbar->bar_name.state_pix[k]) XFreePixmap(server.dsp, tskbar->bar_name.state_pix[k]); + g_free(tskbar->bar_name.name); + tskbar->bar_name.name = NULL; + free_area(&tskbar->bar_name.area); + for (k = 0; k < TASKBAR_STATE_COUNT; ++k) { + if (tskbar->bar_name.state_pix[k]) + XFreePixmap(server.dsp, tskbar->bar_name.state_pix[k]); + tskbar->bar_name.state_pix[k] = 0; } tskbar->area.list = g_slist_remove(tskbar->area.list, &tskbar->bar_name); } } + + pango_font_description_free(taskbarname_font_desc); + taskbarname_font_desc = NULL; }
M src/tint.csrc/tint.c

@@ -271,12 +271,15 @@

if (default_icon) { imlib_context_set_image(default_icon); imlib_free_image(); + default_icon = NULL; } imlib_context_disconnect_display(); cleanup_server(); cleanup_timeout(); - if (server.dsp) XCloseDisplay(server.dsp); + if (server.dsp) + XCloseDisplay(server.dsp); + server.dsp = NULL; #ifdef HAVE_SN if (startup_notifications) {
M src/tooltip/tooltip.csrc/tooltip/tooltip.c

@@ -51,17 +51,20 @@

void cleanup_tooltip() { stop_tooltip_timeout(); - tooltip_hide(0); - tooltip_copy_text(0); - if (g_tooltip.window) XDestroyWindow(server.dsp, g_tooltip.window); - if (g_tooltip.font_desc) pango_font_description_free(g_tooltip.font_desc); + tooltip_hide(NULL); + tooltip_copy_text(NULL); + if (g_tooltip.window) + XDestroyWindow(server.dsp, g_tooltip.window); + g_tooltip.window = 0; + pango_font_description_free(g_tooltip.font_desc); + g_tooltip.font_desc = NULL; } void init_tooltip() { if (!g_tooltip.font_desc) - g_tooltip.font_desc = pango_font_description_from_string("sans 10"); + g_tooltip.font_desc = pango_font_description_from_string(DEFAULT_FONT); if (g_tooltip.bg == 0) g_tooltip.bg = &g_array_index(backgrounds, Background, 0);

@@ -72,7 +75,8 @@ attr.colormap = server.colormap;

attr.background_pixel = 0; attr.border_pixel = 0; unsigned long mask = CWEventMask|CWColormap|CWBorderPixel|CWBackPixel|CWOverrideRedirect; - if (g_tooltip.window) XDestroyWindow(server.dsp, g_tooltip.window); + if (g_tooltip.window) + XDestroyWindow(server.dsp, g_tooltip.window); g_tooltip.window = XCreateWindow(server.dsp, server.root_win, 0, 0, 100, 20, 0, server.depth, InputOutput, server.visual, mask, &attr); }

@@ -296,10 +300,8 @@

void stop_tooltip_timeout() { - if (g_tooltip.timeout) { - stop_timeout(g_tooltip.timeout); - g_tooltip.timeout = 0; - } + stop_timeout(g_tooltip.timeout); + g_tooltip.timeout = NULL; }

@@ -309,6 +311,6 @@ free(g_tooltip.tooltip_text);

if (area && area->_get_tooltip_text) g_tooltip.tooltip_text = strdup(area->_get_tooltip_text(area)); else - g_tooltip.tooltip_text = 0; + g_tooltip.tooltip_text = NULL; g_tooltip.area = area; }
M src/util/area.csrc/util/area.c

@@ -456,6 +456,9 @@

void free_area (Area *a) { + if (!a) + return; + GSList *l0; for (l0 = a->list; l0 ; l0 = l0->next) free_area (l0->data);
M src/util/timer.csrc/util/timer.c

@@ -64,8 +64,8 @@ void stop_multi_timeout(timeout* t);

void default_timeout() { - timeout_list = 0; - multi_timeouts = 0; + timeout_list = NULL; + multi_timeouts = NULL; } void cleanup_timeout()

@@ -79,7 +79,7 @@ timeout_list = g_slist_remove(timeout_list, t);

} if (multi_timeouts) { g_hash_table_destroy(multi_timeouts); - multi_timeouts = 0; + multi_timeouts = NULL; } }