*fix* 2 memleaks
*fix* no more warnings git-svn-id: http://tint2.googlecode.com/svn/trunk@335 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
parent
f9a7bb8b1e
commit
06518a0f4b
8 changed files with 44 additions and 35 deletions
|
@ -87,6 +87,7 @@ time1_font = AvantGardeLTMedium 9 bold
|
|||
clock_font_color = #151515 60
|
||||
clock_padding = 4 0
|
||||
clock_tooltip = %A %d %B
|
||||
clock_background_id = 1
|
||||
#time1_timezone = :US/Hawaii
|
||||
#time2_timezone = :Europe/Berlin
|
||||
#clock_tooltip_timezone = :/usr/share/zoneinfo/Europe/Paris
|
||||
|
|
|
@ -212,36 +212,30 @@ void update_battery() {
|
|||
|
||||
fp = fopen(path_status, "r");
|
||||
if(fp != NULL) {
|
||||
fgets(tmp, sizeof tmp, fp);
|
||||
if (fgets(tmp, sizeof tmp, fp)) {
|
||||
battery_state.state = BATTERY_UNKNOWN;
|
||||
if(strcasecmp(tmp, "Charging\n")==0) battery_state.state = BATTERY_CHARGING;
|
||||
if(strcasecmp(tmp, "Discharging\n")==0) battery_state.state = BATTERY_DISCHARGING;
|
||||
if(strcasecmp(tmp, "Full\n")==0) battery_state.state = BATTERY_FULL;
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
battery_state.state = BATTERY_UNKNOWN;
|
||||
if(strcasecmp(tmp, "Charging\n")==0) battery_state.state = BATTERY_CHARGING;
|
||||
if(strcasecmp(tmp, "Discharging\n")==0) battery_state.state = BATTERY_DISCHARGING;
|
||||
if(strcasecmp(tmp, "Full\n")==0) battery_state.state = BATTERY_FULL;
|
||||
if (battery_state.state == BATTERY_DISCHARGING) {
|
||||
}
|
||||
else {
|
||||
}
|
||||
|
||||
fp = fopen(path_energy_now, "r");
|
||||
if(fp != NULL) {
|
||||
fgets(tmp, sizeof tmp, fp);
|
||||
energy_now = atoi(tmp);
|
||||
if (fgets(tmp, sizeof tmp, fp)) energy_now = atoi(tmp);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
fp = fopen(path_energy_full, "r");
|
||||
if(fp != NULL) {
|
||||
fgets(tmp, sizeof tmp, fp);
|
||||
energy_full = atoi(tmp);
|
||||
if (fgets(tmp, sizeof tmp, fp)) energy_full = atoi(tmp);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
fp = fopen(path_current_now, "r");
|
||||
if(fp != NULL) {
|
||||
fgets(tmp, sizeof tmp, fp);
|
||||
current_now = atoi(tmp);
|
||||
if (fgets(tmp, sizeof tmp, fp)) current_now = atoi(tmp);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
|
@ -268,15 +262,14 @@ void update_battery() {
|
|||
if(energy_full > 0)
|
||||
new_percentage = (energy_now*100)/energy_full;
|
||||
|
||||
if(battery_low_status > new_percentage && battery_state.state == BATTERY_DISCHARGING && !battery_low_cmd_send) {
|
||||
printf("battery low, executing: %s\n", battery_low_cmd);
|
||||
if (battery_low_cmd)
|
||||
system(battery_low_cmd);
|
||||
battery_low_cmd_send = 1;
|
||||
if(battery_low_status > new_percentage && battery_state.state == BATTERY_DISCHARGING && !battery_low_cmd_send) {
|
||||
if (battery_low_cmd)
|
||||
if (-1 != system(battery_low_cmd))
|
||||
battery_low_cmd_send = 1;
|
||||
}
|
||||
if(battery_low_status < new_percentage && battery_state.state == BATTERY_CHARGING && battery_low_cmd_send) {
|
||||
battery_low_cmd_send = 0;
|
||||
}
|
||||
if(battery_low_status < new_percentage && battery_state.state == BATTERY_CHARGING && battery_low_cmd_send) {
|
||||
battery_low_cmd_send = 0;
|
||||
}
|
||||
|
||||
battery_state.percentage = new_percentage;
|
||||
|
||||
|
|
|
@ -318,6 +318,11 @@ void cleanup_panel()
|
|||
pango_font_description_free(panel_config.g_task.font_desc);
|
||||
panel_config.g_task.font_desc = 0;
|
||||
}
|
||||
|
||||
if (backgrounds) {
|
||||
g_array_free(backgrounds, 1);
|
||||
backgrounds = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -85,6 +85,7 @@ void server_init_atoms ()
|
|||
server.atom._NET_SYSTEM_TRAY_ORIENTATION = XInternAtom(server.dsp, "_NET_SYSTEM_TRAY_ORIENTATION", False);
|
||||
server.atom._XEMBED = XInternAtom(server.dsp, "_XEMBED", False);
|
||||
server.atom._XEMBED_INFO = XInternAtom(server.dsp, "_XEMBED_INFO", False);
|
||||
g_free(name_trayer);
|
||||
|
||||
// drag 'n' drop
|
||||
server.atom.XdndAware = XInternAtom(server.dsp, "XdndAware", False);
|
||||
|
@ -95,9 +96,9 @@ void server_init_atoms ()
|
|||
|
||||
void cleanup_server()
|
||||
{
|
||||
XFreeColormap(server.dsp, server.colormap);
|
||||
free(server.monitor);
|
||||
XFreeGC(server.dsp, server.gc);
|
||||
if (server.colormap) XFreeColormap(server.dsp, server.colormap);
|
||||
if (server.monitor) free(server.monitor);
|
||||
if (server.gc) XFreeGC(server.dsp, server.gc);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -67,8 +67,10 @@ Task *add_task (Window win)
|
|||
// even with task_on_all_desktop and with task_on_all_panel
|
||||
new_tsk.title = 0;
|
||||
int k;
|
||||
for (k=0; k<TASK_STATE_COUNT; ++k)
|
||||
for (k=0; k<TASK_STATE_COUNT; ++k) {
|
||||
new_tsk.icon[k] = 0;
|
||||
new_tsk.state_pix[k] = 0;
|
||||
}
|
||||
get_title(&new_tsk);
|
||||
get_icon(&new_tsk);
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ void cleanup()
|
|||
if (snapshot_path) g_free(snapshot_path);
|
||||
|
||||
cleanup_server();
|
||||
XCloseDisplay(server.dsp);
|
||||
if (server.dsp) XCloseDisplay(server.dsp);
|
||||
}
|
||||
|
||||
|
||||
|
@ -801,9 +801,11 @@ int main (int argc, char *argv[])
|
|||
|
||||
default:
|
||||
if (e.type == XDamageNotify+damage_event) {
|
||||
// union needed to avoid strict-aliasing warnings by gcc
|
||||
union { XEvent e; XDamageNotifyEvent de; } event_union = {.e=e};
|
||||
TrayWindow *traywin;
|
||||
GSList *l;
|
||||
XDamageNotifyEvent* de = (XDamageNotifyEvent*)&e;
|
||||
XDamageNotifyEvent* de = &event_union.de;
|
||||
for (l = systray.list_icons; l ; l = l->next) {
|
||||
traywin = (TrayWindow*)l->data;
|
||||
if ( traywin->id == de->drawable && !de->more ) {
|
||||
|
|
|
@ -44,7 +44,9 @@ void copy_file(const char *pathSrc, const char *pathDest)
|
|||
fileDest = fopen(pathDest, "wb");
|
||||
if (fileDest == NULL) return;
|
||||
|
||||
while ((nb = fread(line, 1, 100, fileSrc)) > 0) fwrite(line, 1, nb, fileDest);
|
||||
while ((nb = fread(line, 1, 100, fileSrc)) > 0)
|
||||
if ( nb != fwrite(line, 1, nb, fileDest))
|
||||
printf("Error while copying file %s to %s\n", pathSrc, pathDest);
|
||||
|
||||
fclose (fileDest);
|
||||
fclose (fileSrc);
|
||||
|
|
|
@ -300,7 +300,9 @@ void create_multi_timeout(timeout* t1, timeout* t2)
|
|||
|
||||
t1->multi_timeout = mt1;
|
||||
t2->multi_timeout = mt2;
|
||||
real_timeout->multi_timeout = real_timeout;
|
||||
// set real_timeout->multi_timeout to something, such that we see in add_timeout_intern that
|
||||
// it is already a multi_timeout (we never use it, except of checking for 0 ptr)
|
||||
real_timeout->multi_timeout = (void*)real_timeout;
|
||||
|
||||
timeout_list = g_slist_remove(timeout_list, t1);
|
||||
timeout_list = g_slist_remove(timeout_list, t2);
|
||||
|
@ -411,10 +413,11 @@ void stop_multi_timeout(timeout* t)
|
|||
multi_timeout_handler* mth = g_hash_table_lookup(multi_timeouts, t);
|
||||
g_hash_table_remove(multi_timeouts, mth->parent_timeout);
|
||||
while (mth->timeout_list) {
|
||||
timeout* t = mth->timeout_list->data;
|
||||
mth->timeout_list = g_slist_remove(mth->timeout_list, t);
|
||||
g_hash_table_remove(multi_timeouts, t);
|
||||
free(t);
|
||||
timeout* t1 = mth->timeout_list->data;
|
||||
mth->timeout_list = g_slist_remove(mth->timeout_list, t1);
|
||||
g_hash_table_remove(multi_timeouts, t1);
|
||||
free(t1->multi_timeout);
|
||||
free(t1);
|
||||
}
|
||||
free(mth);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue