diff --git a/src/combine.cc b/src/combine.cc index f44f7dc6..40738480 100644 --- a/src/combine.cc +++ b/src/combine.cc @@ -181,7 +181,6 @@ void free_combine(struct text_object *obj) free(cd->seperation); free(cd->right); free_text_objects(obj->sub); - free(obj->sub); - free(obj->data.opaque); - obj->data.opaque = NULL; + free_and_zero(obj->sub); + free_and_zero(obj->data.opaque); } diff --git a/src/conky.cc b/src/conky.cc index bfdd71df..aec982d0 100644 --- a/src/conky.cc +++ b/src/conky.cc @@ -682,8 +682,6 @@ void conftree_empty(struct conftree* tree) { struct conftree *currentconffile; -#define free_and_zero(PTR) if(PTR) { free(PTR); PTR = NULL; } - static void extract_variable_text(const char *p) { free_text_objects(&global_root_object); diff --git a/src/core.h b/src/core.h index ed4ff091..89263228 100644 --- a/src/core.h +++ b/src/core.h @@ -28,6 +28,8 @@ * */ +#define free_and_zero(PTR) if(PTR) { free(PTR); PTR = NULL; } + #ifndef _CONKY_CORE_H_ #define _CONKY_CORE_H_