1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-28 13:00:45 +00:00

Use free_and_zero in [d-k]*.cc where appropriate

This commit is contained in:
Nikolas Garofil 2010-02-23 23:13:11 +01:00
parent f236523f30
commit 72d581279a
5 changed files with 14 additions and 41 deletions

View File

@ -50,8 +50,7 @@ void clear_diskio_stats(void)
while (stats.next) {
cur = stats.next;
stats.next = stats.next->next;
if (cur->dev)
free(cur->dev);
free_and_zero(cur->dev);
free(cur);
}
}
@ -150,8 +149,7 @@ void parse_diskiograph_arg(struct text_object *obj, const char *arg)
buf = scan_graph(obj, arg, 0);
obj->data.opaque = prepare_diskio_stat(dev_name(buf));
if (buf)
free(buf);
free_and_zero(buf);
}
double diskiographval(struct text_object *obj)

View File

@ -437,8 +437,5 @@ void print_eve(struct text_object *obj, char *p, int p_max_size)
void free_eve(struct text_object *obj)
{
if (obj->data.opaque) {
free(obj->data.opaque);
obj->data.opaque = NULL;
}
free_and_zero(obj->data.opaque);
}

View File

@ -204,8 +204,7 @@ static void threaded_exec(thread_handle &handle, struct text_object *obj)
{
std::lock_guard<std::mutex> lock(handle.mutex());
if (ed->buffer)
free(ed->buffer);
free_and_zero(ed->buffer);
ed->buffer = buff;
}
if (handle.test(0)) {
@ -364,10 +363,7 @@ double execi_barval(struct text_object *obj)
void free_exec(struct text_object *obj)
{
if (obj->data.s) {
free(obj->data.s);
obj->data.s = NULL;
}
free_and_zero(obj->data.s);
}
void free_execi(struct text_object *obj)
@ -380,10 +376,8 @@ void free_execi(struct text_object *obj)
if (ed->p_timed_thread) {
ed->p_timed_thread.reset();
}
if (ed->cmd)
free(ed->cmd);
if (ed->buffer)
free(ed->buffer);
free_and_zero(ed->cmd);
free_and_zero(ed->buffer);
delete ed;
obj->data.opaque = NULL;
}

View File

@ -74,9 +74,7 @@ int add_font(const char *data_in)
}
font_count++;
if (font_count == 0) {
if (fonts != NULL) {
free(fonts);
}
free_and_zero(fonts);
if ((fonts = (struct font_list *) malloc(sizeof(struct font_list)))
== NULL) {
CRIT_ERR(NULL, NULL, "malloc");
@ -148,10 +146,7 @@ void free_fonts(void)
}
}
}
if (fonts) {
free(fonts);
fonts = 0;
}
free_and_zero(fonts);
font_count = -1;
selected_font = 0;
#ifdef BUILD_XFT

View File

@ -59,15 +59,13 @@ struct hdd_info hdd_info_head;
void set_hddtemp_host(const char *host)
{
if (hddtemp_host)
free(hddtemp_host);
free_and_zero(hddtemp_host);
hddtemp_host = strdup(host);
}
void set_hddtemp_port(const char *port)
{
if (hddtemp_port)
free(hddtemp_port);
free_and_zero(hddtemp_port);
hddtemp_port = strdup(port);
}
@ -237,18 +235,9 @@ void update_hddtemp(void) {
void free_hddtemp(struct text_object *obj)
{
free_hddtemp_info();
if (hddtemp_host) {
free(hddtemp_host);
hddtemp_host = NULL;
}
if (hddtemp_port) {
free(hddtemp_port);
hddtemp_port = NULL;
}
if (obj->data.s) {
free(obj->data.s);
obj->data.s = NULL;
}
free_and_zero(hddtemp_host);
free_and_zero(hddtemp_port);
free_and_zero(obj->data.s);
}
static int get_hddtemp_info(const char *dev, short *val, char *unit)