mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-18 02:55:12 +00:00
cleanup free_text_objects()
This commit is contained in:
parent
3f00e817c5
commit
b6a57a8f77
@ -174,7 +174,7 @@ void free_combine(struct text_object *obj)
|
||||
free(cd->left);
|
||||
free(cd->seperation);
|
||||
free(cd->right);
|
||||
free_text_objects(obj->sub, 1);
|
||||
free_text_objects(obj->sub);
|
||||
free(obj->sub);
|
||||
free(obj->data.opaque);
|
||||
obj->data.opaque = NULL;
|
||||
|
@ -671,7 +671,7 @@ struct conftree *currentconffile;
|
||||
|
||||
static void extract_variable_text(const char *p)
|
||||
{
|
||||
free_text_objects(&global_root_object, 0);
|
||||
free_text_objects(&global_root_object);
|
||||
if (tmpstring1) {
|
||||
free(tmpstring1);
|
||||
tmpstring1 = 0;
|
||||
@ -787,7 +787,7 @@ void evaluate(const char *text, char *p, int p_max_size)
|
||||
parse_conky_vars(&subroot, text, p, p_max_size);
|
||||
DBGP("evaluated '%s' to '%s'", text, p);
|
||||
|
||||
free_text_objects(&subroot, 1);
|
||||
free_text_objects(&subroot);
|
||||
}
|
||||
|
||||
double current_update_time, next_update_time, last_update_time;
|
||||
@ -2398,7 +2398,7 @@ void clean_up(void *memtofree1, void* memtofree2)
|
||||
free_desktop_info();
|
||||
#endif /* X11 */
|
||||
|
||||
free_text_objects(&global_root_object, 0);
|
||||
free_text_objects(&global_root_object);
|
||||
if (tmpstring1) {
|
||||
free(tmpstring1);
|
||||
tmpstring1 = 0;
|
||||
|
20
src/core.c
20
src/core.c
@ -1795,41 +1795,29 @@ int extract_variable_text_internal(struct text_object *retval, const char *const
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Frees the list of text objects root points to. When internal = 1, it won't
|
||||
* free global objects.
|
||||
*/
|
||||
void free_text_objects(struct text_object *root, int internal)
|
||||
/* Frees the list of text objects root points to. */
|
||||
void free_text_objects(struct text_object *root)
|
||||
{
|
||||
struct text_object *obj;
|
||||
|
||||
(void)internal;
|
||||
|
||||
if (!root->prev) {
|
||||
return;
|
||||
}
|
||||
|
||||
#define data obj->data
|
||||
for (obj = root->prev; obj; obj = root->prev) {
|
||||
root->prev = obj->prev;
|
||||
|
||||
if (obj->callbacks.free) {
|
||||
(*obj->callbacks.free)(obj);
|
||||
goto obj_free_loop_tail;
|
||||
}
|
||||
|
||||
switch (obj->type) {
|
||||
default: break;
|
||||
}
|
||||
obj_free_loop_tail:
|
||||
if(obj->sub) {
|
||||
free_text_objects(obj->sub, 1);
|
||||
free_text_objects(obj->sub);
|
||||
free(obj->sub);
|
||||
}
|
||||
if(obj->special_data)
|
||||
free(obj->special_data);
|
||||
|
||||
free(obj);
|
||||
}
|
||||
#undef data
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ size_t remove_comments(char *string);
|
||||
|
||||
int extract_variable_text_internal(struct text_object *retval, const char *const_p);
|
||||
|
||||
void free_text_objects(struct text_object *root, int internal);
|
||||
void free_text_objects(struct text_object *root);
|
||||
|
||||
const char *dev_name(const char *);
|
||||
|
||||
|
@ -287,7 +287,7 @@ void print_execp(struct text_object *obj, char *p, int p_max_size)
|
||||
read_exec(obj->data.s, buf, text_buffer_size);
|
||||
parse_conky_vars(&subroot, buf, p, p_max_size);
|
||||
|
||||
free_text_objects(&subroot, 1);
|
||||
free_text_objects(&subroot);
|
||||
free(buf);
|
||||
}
|
||||
|
||||
@ -323,7 +323,7 @@ void print_execpi(struct text_object *obj, char *p, int p_max_size)
|
||||
ed->last_update = current_update_time;
|
||||
}
|
||||
parse_conky_vars(&subroot, ed->buffer, p, p_max_size);
|
||||
free_text_objects(&subroot, 1);
|
||||
free_text_objects(&subroot);
|
||||
}
|
||||
|
||||
void print_texeci(struct text_object *obj, char *p, int p_max_size)
|
||||
|
@ -157,7 +157,7 @@ void free_scroll(struct text_object *obj)
|
||||
if (sd->text)
|
||||
free(sd->text);
|
||||
if (obj->sub) {
|
||||
free_text_objects(obj->sub, 1);
|
||||
free_text_objects(obj->sub);
|
||||
free(obj->sub);
|
||||
obj->sub = NULL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user