all repos — tint2 @ dca5c2586c748e83bb75ea0040a466b0678d6c1d

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

Merge branch 'sre/tint2-fix-battery-memleak'
o9000 o9000
commit

dca5c2586c748e83bb75ea0040a466b0678d6c1d

parent

5b01670a22c2bab9aae67174a3f806a7047bee92

2 files changed, 24 insertions(+), 29 deletions(-)

jump to
M src/battery/battery.csrc/battery/battery.c

@@ -168,6 +168,10 @@ free(battery_uwheel_command);

battery_uwheel_command = NULL; free(battery_dwheel_command); battery_dwheel_command = NULL; + free(ac_connected_cmd); + ac_connected_cmd = NULL; + free(ac_disconnected_cmd); + ac_disconnected_cmd = NULL; stop_timeout(battery_timeout); battery_timeout = NULL; battery_found = 0;
M src/battery/linux.csrc/battery/linux.c

@@ -193,40 +193,31 @@

return TRUE; } -void battery_os_free() { - GList *l = batteries; +static void psy_battery_free(gpointer data) { + struct psy_battery *bat = data; + g_free(bat->name); + g_free(bat->path_status); + g_free(bat->path_power_now); + g_free(bat->path_energy_full); + g_free(bat->path_energy_now); + g_free(bat->path_present); + g_free(bat); +} + +static void psy_mains_free(gpointer data) { + struct psy_mains *ac = data; + g_free(ac->name); + g_free(ac->path_online); + g_free(ac); +} +void battery_os_free() { uevent_unregister_notifier(&psy_change); uevent_unregister_notifier(&psy_plug); - while (l != NULL) { - GList *next = l->next; - struct psy_battery *bat = l->data; - - g_free(bat->name); - g_free(bat->path_status); - g_free(bat->path_power_now); - g_free(bat->path_energy_full); - g_free(bat->path_energy_now); - g_free(bat->path_present); - - batteries = g_list_delete_link(batteries, l); - l = next; - } - - l = mains; - while (l != NULL) { - GList *next = l->next; - struct psy_mains *ac = l->data; - - g_free(ac->name); - g_free(ac->path_online); - - mains = g_list_delete_link(mains, l); - l = next; - } - + g_list_free_full(batteries, psy_battery_free); batteries = NULL; + g_list_free_full(mains, psy_mains_free); mains = NULL; }