X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;ds=sidebyside;f=src%2Fbattery%2Fbattery.c;h=7e47bd32699a8f2ee9a740b3ae099372d2f2f723;hb=06f401f585a2c0f86dd2d8968f480039ca051122;hp=4dcb99a47cffab9755daa5ea7b29599fb69f717d;hpb=ddd6fcc40dbe9d4257ff904d5e156b7f612dedc4;p=chaz%2Ftint2 diff --git a/src/battery/battery.c b/src/battery/battery.c index 4dcb99a..7e47bd3 100644 --- a/src/battery/battery.c +++ b/src/battery/battery.c @@ -47,7 +47,7 @@ char *path_energy_now, *path_energy_full, *path_current_now, *path_status; void init_battery() { // check battery - GDir *directory; + GDir *directory = 0; GError *error = NULL; const char *entryname; char *battery_dir = 0; @@ -69,7 +69,9 @@ void init_battery() g_free(path1); } } - if (battery_dir != 0) { + if (directory) + g_dir_close(directory); + if (battery_dir) { char *path1 = g_build_filename(battery_dir, "energy_now", NULL); if (g_file_test (path1, G_FILE_TEST_EXISTS)) { path_energy_now = g_build_filename(battery_dir, "energy_now", NULL); @@ -94,9 +96,9 @@ void init_battery() } FILE *fp; - Panel *panel; - Battery *battery; - int i, bat_percentage_height, bat_percentage_height_ink, bat_time_height, bat_time_height_ink; + Panel *panel; + Battery *battery; + int i, bat_percentage_height, bat_percentage_height_ink, bat_time_height, bat_time_height_ink; for (i=0 ; i < nb_panel ; i++) { panel = &panel1[i]; @@ -161,6 +163,9 @@ void init_battery() battery->bat1_posy -= ((bat_time_height_ink + 2) / 2); battery->bat2_posy = battery->bat1_posy + bat_percentage_height + 2 - (bat_percentage_height - bat_percentage_height_ink)/2 - (bat_time_height - bat_time_height_ink)/2; } + + if (battery_dir) + g_free(battery_dir); } @@ -268,7 +273,7 @@ void draw_battery (void *obj, cairo_t *c, int active) void resize_battery(void *obj) { - Battery *battery = obj; + Battery *battery = obj; PangoLayout *layout; int percentage_width, time_width, new_width;