mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-29 05:12:41 +00:00
Use free_and_zero in [d-k]*.cc where appropriate
This commit is contained in:
parent
f236523f30
commit
72d581279a
@ -50,8 +50,7 @@ void clear_diskio_stats(void)
|
|||||||
while (stats.next) {
|
while (stats.next) {
|
||||||
cur = stats.next;
|
cur = stats.next;
|
||||||
stats.next = stats.next->next;
|
stats.next = stats.next->next;
|
||||||
if (cur->dev)
|
free_and_zero(cur->dev);
|
||||||
free(cur->dev);
|
|
||||||
free(cur);
|
free(cur);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -150,8 +149,7 @@ void parse_diskiograph_arg(struct text_object *obj, const char *arg)
|
|||||||
buf = scan_graph(obj, arg, 0);
|
buf = scan_graph(obj, arg, 0);
|
||||||
|
|
||||||
obj->data.opaque = prepare_diskio_stat(dev_name(buf));
|
obj->data.opaque = prepare_diskio_stat(dev_name(buf));
|
||||||
if (buf)
|
free_and_zero(buf);
|
||||||
free(buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double diskiographval(struct text_object *obj)
|
double diskiographval(struct text_object *obj)
|
||||||
|
@ -437,8 +437,5 @@ void print_eve(struct text_object *obj, char *p, int p_max_size)
|
|||||||
|
|
||||||
void free_eve(struct text_object *obj)
|
void free_eve(struct text_object *obj)
|
||||||
{
|
{
|
||||||
if (obj->data.opaque) {
|
free_and_zero(obj->data.opaque);
|
||||||
free(obj->data.opaque);
|
|
||||||
obj->data.opaque = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
14
src/exec.cc
14
src/exec.cc
@ -204,8 +204,7 @@ static void threaded_exec(thread_handle &handle, struct text_object *obj)
|
|||||||
|
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(handle.mutex());
|
std::lock_guard<std::mutex> lock(handle.mutex());
|
||||||
if (ed->buffer)
|
free_and_zero(ed->buffer);
|
||||||
free(ed->buffer);
|
|
||||||
ed->buffer = buff;
|
ed->buffer = buff;
|
||||||
}
|
}
|
||||||
if (handle.test(0)) {
|
if (handle.test(0)) {
|
||||||
@ -364,10 +363,7 @@ double execi_barval(struct text_object *obj)
|
|||||||
|
|
||||||
void free_exec(struct text_object *obj)
|
void free_exec(struct text_object *obj)
|
||||||
{
|
{
|
||||||
if (obj->data.s) {
|
free_and_zero(obj->data.s);
|
||||||
free(obj->data.s);
|
|
||||||
obj->data.s = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_execi(struct text_object *obj)
|
void free_execi(struct text_object *obj)
|
||||||
@ -380,10 +376,8 @@ void free_execi(struct text_object *obj)
|
|||||||
if (ed->p_timed_thread) {
|
if (ed->p_timed_thread) {
|
||||||
ed->p_timed_thread.reset();
|
ed->p_timed_thread.reset();
|
||||||
}
|
}
|
||||||
if (ed->cmd)
|
free_and_zero(ed->cmd);
|
||||||
free(ed->cmd);
|
free_and_zero(ed->buffer);
|
||||||
if (ed->buffer)
|
|
||||||
free(ed->buffer);
|
|
||||||
delete ed;
|
delete ed;
|
||||||
obj->data.opaque = NULL;
|
obj->data.opaque = NULL;
|
||||||
}
|
}
|
||||||
|
@ -74,9 +74,7 @@ int add_font(const char *data_in)
|
|||||||
}
|
}
|
||||||
font_count++;
|
font_count++;
|
||||||
if (font_count == 0) {
|
if (font_count == 0) {
|
||||||
if (fonts != NULL) {
|
free_and_zero(fonts);
|
||||||
free(fonts);
|
|
||||||
}
|
|
||||||
if ((fonts = (struct font_list *) malloc(sizeof(struct font_list)))
|
if ((fonts = (struct font_list *) malloc(sizeof(struct font_list)))
|
||||||
== NULL) {
|
== NULL) {
|
||||||
CRIT_ERR(NULL, NULL, "malloc");
|
CRIT_ERR(NULL, NULL, "malloc");
|
||||||
@ -148,10 +146,7 @@ void free_fonts(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fonts) {
|
free_and_zero(fonts);
|
||||||
free(fonts);
|
|
||||||
fonts = 0;
|
|
||||||
}
|
|
||||||
font_count = -1;
|
font_count = -1;
|
||||||
selected_font = 0;
|
selected_font = 0;
|
||||||
#ifdef BUILD_XFT
|
#ifdef BUILD_XFT
|
||||||
|
@ -59,15 +59,13 @@ struct hdd_info hdd_info_head;
|
|||||||
|
|
||||||
void set_hddtemp_host(const char *host)
|
void set_hddtemp_host(const char *host)
|
||||||
{
|
{
|
||||||
if (hddtemp_host)
|
free_and_zero(hddtemp_host);
|
||||||
free(hddtemp_host);
|
|
||||||
hddtemp_host = strdup(host);
|
hddtemp_host = strdup(host);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_hddtemp_port(const char *port)
|
void set_hddtemp_port(const char *port)
|
||||||
{
|
{
|
||||||
if (hddtemp_port)
|
free_and_zero(hddtemp_port);
|
||||||
free(hddtemp_port);
|
|
||||||
hddtemp_port = strdup(port);
|
hddtemp_port = strdup(port);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,18 +235,9 @@ void update_hddtemp(void) {
|
|||||||
void free_hddtemp(struct text_object *obj)
|
void free_hddtemp(struct text_object *obj)
|
||||||
{
|
{
|
||||||
free_hddtemp_info();
|
free_hddtemp_info();
|
||||||
if (hddtemp_host) {
|
free_and_zero(hddtemp_host);
|
||||||
free(hddtemp_host);
|
free_and_zero(hddtemp_port);
|
||||||
hddtemp_host = NULL;
|
free_and_zero(obj->data.s);
|
||||||
}
|
|
||||||
if (hddtemp_port) {
|
|
||||||
free(hddtemp_port);
|
|
||||||
hddtemp_port = NULL;
|
|
||||||
}
|
|
||||||
if (obj->data.s) {
|
|
||||||
free(obj->data.s);
|
|
||||||
obj->data.s = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_hddtemp_info(const char *dev, short *val, char *unit)
|
static int get_hddtemp_info(const char *dev, short *val, char *unit)
|
||||||
|
Loading…
Reference in New Issue
Block a user