Properly free the list of parts, and the private data.

2001-08-07  Not Zed  <NotZed@Ximian.com>

        * filter-rule.c (filter_rule_finalise): Properly free the list of
        parts, and the private data.
        (FilterRulePrivate): Remove unused 'parts' member.

        * filter-option.c (free_option): For freeing options.
        (filter_option_finalise): Free options list.

        * filter-element.c (filter_element_finalise): free name.

        * filter-input.c (filter_input_finalise): Free type and values
        list.

        * filter-context.c (filter_context_finalise): Free the actions.

        * rule-context.c (rule_context_finalise): Remove the totally weird
        arsed *_set_list free code.
        (free_part_set):
        (free_rule_set): Use this to free stuff using g_list_foreach.
        (rule_context_finalise): Free the error string.
        (rule_context_finalise): Free the rules and parts.

svn path=/trunk/; revision=11774
This commit is contained in:
Not Zed
2001-08-08 09:39:56 +00:00
committed by Michael Zucci
parent e835aa2faf
commit bbfda4227e
7 changed files with 82 additions and 37 deletions

View File

@ -1,3 +1,26 @@
2001-08-07 Not Zed <NotZed@Ximian.com>
* filter-rule.c (filter_rule_finalise): Properly free the list of
parts, and the private data.
(FilterRulePrivate): Remove unused 'parts' member.
* filter-option.c (free_option): For freeing options.
(filter_option_finalise): Free options list.
* filter-element.c (filter_element_finalise): free name.
* filter-input.c (filter_input_finalise): Free type and values
list.
* filter-context.c (filter_context_finalise): Free the actions.
* rule-context.c (rule_context_finalise): Remove the totally weird
arsed *_set_list free code.
(free_part_set):
(free_rule_set): Use this to free stuff using g_list_foreach.
(rule_context_finalise): Free the error string.
(rule_context_finalise): Free the rules and parts.
2001-08-07 Jeffrey Stedfast <fejj@ximian.com>
* filtertypes.xml: Reverted my previous change, I fixed the filter

View File

@ -105,7 +105,8 @@ filter_context_finalise(GtkObject *obj)
{
FilterContext *o = (FilterContext *)obj;
o = o;
g_list_foreach(o->actions, (GFunc)gtk_object_unref, NULL);
g_list_free(o->actions);
((GtkObjectClass *)(parent_class))->finalize(obj);
}

View File

@ -110,7 +110,7 @@ filter_element_finalise (GtkObject *obj)
{
FilterElement *o = (FilterElement *)obj;
o = o;
g_free(o->name);
((GtkObjectClass *)(parent_class))->finalize(obj);
}

View File

@ -120,8 +120,12 @@ static void
filter_input_finalise (GtkObject *obj)
{
FilterInput *o = (FilterInput *)obj;
o = o;
g_free(o->type);
g_list_foreach(o->values, (GFunc)g_free, NULL);
g_list_free(o->values);
g_free(o->priv);
((GtkObjectClass *)(parent_class))->finalize(obj);
}
@ -269,7 +273,8 @@ xml_decode (FilterElement *fe, xmlNodePtr node)
gchar *decstr;
str = xmlNodeGetContent (n);
decstr = e_utf8_xml1_decode (str);
if (str) xmlFree (str);
if (str)
xmlFree (str);
d(printf (" '%s'\n", decstr));
fi->values = g_list_append (fi->values, decstr);
} else {

View File

@ -112,12 +112,22 @@ filter_option_init (FilterOption *o)
o->priv = g_malloc0 (sizeof (*o->priv));
}
static void
free_option(struct _filter_option *o, void *data)
{
g_free(o->title);
g_free(o->value);
g_free(o->code);
g_free(o);
}
static void
filter_option_finalise (GtkObject *obj)
{
FilterOption *o = (FilterOption *)obj;
o = o;
g_list_foreach(o->options, (GFunc)free_option, NULL);
g_list_free(o->options);
((GtkObjectClass *)(parent_class))->finalize(obj);
}

View File

@ -51,7 +51,6 @@ static void filter_rule_finalise (GtkObject * obj);
#define _PRIVATE(x) (((FilterRule *)(x))->priv)
struct _FilterRulePrivate {
GtkWidget *parts; /* where the parts are stored */
};
static GtkObjectClass *parent_class;
@ -112,15 +111,6 @@ filter_rule_init (FilterRule * o)
o->priv = g_malloc0 (sizeof (*o->priv));
}
static void
unref_list (GList * l)
{
while (l) {
gtk_object_unref (GTK_OBJECT (l->data));
l = g_list_next (l);
}
}
static void
filter_rule_finalise (GtkObject * obj)
{
@ -128,7 +118,10 @@ filter_rule_finalise (GtkObject * obj)
g_free (o->name);
g_free (o->source);
unref_list (o->parts);
g_list_foreach(o->parts, (GFunc)gtk_object_unref, NULL);
g_list_free(o->parts);
g_free(o->priv);
((GtkObjectClass *) (parent_class))->finalize(obj);
}

View File

@ -102,38 +102,47 @@ rule_context_init(RuleContext * o)
o->rule_set_map = g_hash_table_new(g_str_hash, g_str_equal);
}
static void
free_part_set(struct _part_set_map *map, void *data)
{
g_free(map->name);
g_free(map);
}
static void
free_rule_set(struct _rule_set_map *map, void *data)
{
g_free(map->name);
g_free(map);
}
static void
rule_context_finalise(GtkObject * obj)
{
RuleContext *o = (RuleContext *) obj;
struct _part_set_map *psm;
struct _rule_set_map *rsm;
GList *next;
g_free(o->priv);
g_hash_table_destroy(o->part_set_map);
g_list_foreach(o->rule_set_list, (GFunc)free_rule_set, NULL);
g_list_free(o->rule_set_list);
g_hash_table_destroy(o->rule_set_map);
for (; o->part_set_list; o->part_set_list = next) {
psm = o->part_set_list->data;
g_free (psm->name);
g_free (psm);
next = o->part_set_list->next;
g_list_free_1 (o->part_set_list);
}
for (; o->rule_set_list; o->rule_set_list = next) {
rsm = o->rule_set_list->data;
g_free (rsm->name);
g_free (rsm);
next = o->rule_set_list->next;
g_list_free_1 (o->rule_set_list);
}
g_list_foreach(o->part_set_list, (GFunc)free_part_set, NULL);
g_list_free(o->part_set_list);
g_hash_table_destroy(o->part_set_map);
g_free(o->error);
g_list_foreach(o->parts, (GFunc)gtk_object_unref, NULL);
g_list_free(o->parts);
g_list_foreach(o->rules, (GFunc)gtk_object_unref, NULL);
g_list_free(o->rules);
if (o->system)
xmlFreeDoc(o->system);
if (o->user)
xmlFreeDoc(o->user);
g_free(o->priv);
((GtkObjectClass *) (parent_class))->finalize(obj);
}
@ -157,6 +166,8 @@ rule_context_add_part_set(RuleContext * f, const char *setname, int part_type, R
{
struct _part_set_map *map;
g_assert(g_hash_table_lookup(f->part_set_map, setname) == NULL);
map = g_malloc0(sizeof(*map));
map->type = part_type;
map->append = append;
@ -172,6 +183,8 @@ rule_context_add_rule_set(RuleContext * f, const char *setname, int rule_type, R
{
struct _rule_set_map *map;
g_assert(g_hash_table_lookup(f->rule_set_map, setname) == NULL);
map = g_malloc0(sizeof(*map));
map->type = rule_type;
map->append = append;