mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-27 04:32:55 +00:00
simplify free_text_objects a bit
This commit is contained in:
parent
a98d6e06ac
commit
0f7ac0f5af
68
src/conky.c
68
src/conky.c
@ -1612,46 +1612,47 @@ static void free_text_objects(struct text_object_list *text_object_list, char fu
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define data obj->data
|
||||||
for (i = 0; i < text_object_list->text_object_count; i++) {
|
for (i = 0; i < text_object_list->text_object_count; i++) {
|
||||||
obj = &text_object_list->text_objects[i];
|
obj = &text_object_list->text_objects[i];
|
||||||
switch (obj->type) {
|
switch (obj->type) {
|
||||||
#ifndef __OpenBSD__
|
#ifndef __OpenBSD__
|
||||||
case OBJ_acpitemp:
|
case OBJ_acpitemp:
|
||||||
close(obj->data.i);
|
close(data.i);
|
||||||
break;
|
break;
|
||||||
case OBJ_i2c:
|
case OBJ_i2c:
|
||||||
case OBJ_platform:
|
case OBJ_platform:
|
||||||
case OBJ_hwmon:
|
case OBJ_hwmon:
|
||||||
close(obj->data.sysfs.fd);
|
close(data.sysfs.fd);
|
||||||
break;
|
break;
|
||||||
#endif /* !__OpenBSD__ */
|
#endif /* !__OpenBSD__ */
|
||||||
case OBJ_time:
|
case OBJ_time:
|
||||||
case OBJ_utime:
|
case OBJ_utime:
|
||||||
free(obj->data.s);
|
free(data.s);
|
||||||
break;
|
break;
|
||||||
case OBJ_tztime:
|
case OBJ_tztime:
|
||||||
free(obj->data.tztime.tz);
|
free(data.tztime.tz);
|
||||||
free(obj->data.tztime.fmt);
|
free(data.tztime.fmt);
|
||||||
break;
|
break;
|
||||||
case OBJ_mboxscan:
|
case OBJ_mboxscan:
|
||||||
free(obj->data.mboxscan.args);
|
free(data.mboxscan.args);
|
||||||
free(obj->data.mboxscan.output);
|
free(data.mboxscan.output);
|
||||||
break;
|
break;
|
||||||
case OBJ_mails:
|
case OBJ_mails:
|
||||||
case OBJ_new_mails:
|
case OBJ_new_mails:
|
||||||
free(obj->data.local_mail.box);
|
free(data.local_mail.box);
|
||||||
break;
|
break;
|
||||||
case OBJ_imap:
|
case OBJ_imap:
|
||||||
free(info.mail);
|
free(info.mail);
|
||||||
break;
|
break;
|
||||||
case OBJ_imap_unseen:
|
case OBJ_imap_unseen:
|
||||||
if (!obj->global_mode) {
|
if (!obj->global_mode) {
|
||||||
free(obj->data.mail);
|
free(data.mail);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OBJ_imap_messages:
|
case OBJ_imap_messages:
|
||||||
if (!obj->global_mode) {
|
if (!obj->global_mode) {
|
||||||
free(obj->data.mail);
|
free(data.mail);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OBJ_pop3:
|
case OBJ_pop3:
|
||||||
@ -1659,24 +1660,24 @@ static void free_text_objects(struct text_object_list *text_object_list, char fu
|
|||||||
break;
|
break;
|
||||||
case OBJ_pop3_unseen:
|
case OBJ_pop3_unseen:
|
||||||
if (!obj->global_mode) {
|
if (!obj->global_mode) {
|
||||||
free(obj->data.mail);
|
free(data.mail);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OBJ_pop3_used:
|
case OBJ_pop3_used:
|
||||||
if (!obj->global_mode) {
|
if (!obj->global_mode) {
|
||||||
free(obj->data.mail);
|
free(data.mail);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OBJ_if_empty:
|
case OBJ_if_empty:
|
||||||
case OBJ_if_existing:
|
case OBJ_if_existing:
|
||||||
case OBJ_if_mounted:
|
case OBJ_if_mounted:
|
||||||
case OBJ_if_running:
|
case OBJ_if_running:
|
||||||
free(obj->data.ifblock.s);
|
free(data.ifblock.s);
|
||||||
free(obj->data.ifblock.str);
|
free(data.ifblock.str);
|
||||||
break;
|
break;
|
||||||
case OBJ_tail:
|
case OBJ_tail:
|
||||||
free(obj->data.tail.logfile);
|
free(data.tail.logfile);
|
||||||
free(obj->data.tail.buffer);
|
free(data.tail.buffer);
|
||||||
break;
|
break;
|
||||||
case OBJ_text:
|
case OBJ_text:
|
||||||
case OBJ_font:
|
case OBJ_font:
|
||||||
@ -1685,7 +1686,7 @@ static void free_text_objects(struct text_object_list *text_object_list, char fu
|
|||||||
case OBJ_execbar:
|
case OBJ_execbar:
|
||||||
case OBJ_execgraph:
|
case OBJ_execgraph:
|
||||||
case OBJ_execp:
|
case OBJ_execp:
|
||||||
free(obj->data.s);
|
free(data.s);
|
||||||
break;
|
break;
|
||||||
#ifdef HAVE_ICONV
|
#ifdef HAVE_ICONV
|
||||||
case OBJ_iconv_start:
|
case OBJ_iconv_start:
|
||||||
@ -1804,30 +1805,30 @@ static void free_text_objects(struct text_object_list *text_object_list, char fu
|
|||||||
#endif
|
#endif
|
||||||
#ifdef RSS
|
#ifdef RSS
|
||||||
case OBJ_rss:
|
case OBJ_rss:
|
||||||
free(obj->data.rss.uri);
|
free(data.rss.uri);
|
||||||
free(obj->data.rss.action);
|
free(data.rss.action);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case OBJ_pre_exec:
|
case OBJ_pre_exec:
|
||||||
break;
|
break;
|
||||||
#ifndef __OpenBSD__
|
#ifndef __OpenBSD__
|
||||||
case OBJ_battery:
|
case OBJ_battery:
|
||||||
free(obj->data.s);
|
free(data.s);
|
||||||
break;
|
break;
|
||||||
case OBJ_battery_time:
|
case OBJ_battery_time:
|
||||||
free(obj->data.s);
|
free(data.s);
|
||||||
break;
|
break;
|
||||||
#endif /* !__OpenBSD__ */
|
#endif /* !__OpenBSD__ */
|
||||||
case OBJ_execpi:
|
case OBJ_execpi:
|
||||||
case OBJ_execi:
|
case OBJ_execi:
|
||||||
case OBJ_execibar:
|
case OBJ_execibar:
|
||||||
case OBJ_execigraph:
|
case OBJ_execigraph:
|
||||||
free(obj->data.execi.cmd);
|
free(data.execi.cmd);
|
||||||
free(obj->data.execi.buffer);
|
free(data.execi.buffer);
|
||||||
break;
|
break;
|
||||||
case OBJ_texeci:
|
case OBJ_texeci:
|
||||||
free(obj->data.texeci.cmd);
|
free(data.texeci.cmd);
|
||||||
free(obj->data.texeci.buffer);
|
free(data.texeci.buffer);
|
||||||
break;
|
break;
|
||||||
case OBJ_nameserver:
|
case OBJ_nameserver:
|
||||||
free_dns_data();
|
free_dns_data();
|
||||||
@ -1841,10 +1842,10 @@ static void free_text_objects(struct text_object_list *text_object_list, char fu
|
|||||||
break;
|
break;
|
||||||
#ifdef HDDTEMP
|
#ifdef HDDTEMP
|
||||||
case OBJ_hddtemp:
|
case OBJ_hddtemp:
|
||||||
free(obj->data.hddtemp.dev);
|
free(data.hddtemp.dev);
|
||||||
free(obj->data.hddtemp.addr);
|
free(data.hddtemp.addr);
|
||||||
if (obj->data.hddtemp.temp)
|
if (data.hddtemp.temp)
|
||||||
free(obj->data.hddtemp.temp);
|
free(data.hddtemp.temp);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case OBJ_entropy_avail:
|
case OBJ_entropy_avail:
|
||||||
@ -1874,11 +1875,11 @@ static void free_text_objects(struct text_object_list *text_object_list, char fu
|
|||||||
case OBJ_smapi_bat_perc:
|
case OBJ_smapi_bat_perc:
|
||||||
case OBJ_smapi_bat_temp:
|
case OBJ_smapi_bat_temp:
|
||||||
case OBJ_smapi_bat_power:
|
case OBJ_smapi_bat_power:
|
||||||
free(obj->data.s);
|
free(data.s);
|
||||||
break;
|
break;
|
||||||
case OBJ_if_smapi_bat_installed:
|
case OBJ_if_smapi_bat_installed:
|
||||||
free(obj->data.ifblock.s);
|
free(data.ifblock.s);
|
||||||
free(obj->data.ifblock.str);
|
free(data.ifblock.str);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#ifdef NVIDIA
|
#ifdef NVIDIA
|
||||||
@ -1927,10 +1928,11 @@ static void free_text_objects(struct text_object_list *text_object_list, char fu
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case OBJ_scroll:
|
case OBJ_scroll:
|
||||||
free(obj->data.scroll.text);
|
free(data.scroll.text);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#undef data
|
||||||
if (full) {} // disable warning when MPD !defined
|
if (full) {} // disable warning when MPD !defined
|
||||||
free(text_object_list->text_objects);
|
free(text_object_list->text_objects);
|
||||||
text_object_list->text_objects = NULL;
|
text_object_list->text_objects = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user