void init_battery()
{
// check battery
- GDir *directory;
+ GDir *directory = 0;
GError *error = NULL;
const char *entryname;
char *battery_dir = 0;
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);
}
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];
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);
}
void resize_battery(void *obj)
{
- Battery *battery = obj;
+ Battery *battery = obj;
PangoLayout *layout;
int percentage_width, time_width, new_width;