aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2001-08-08 17:39:56 +0800
committerMichael Zucci <zucchi@src.gnome.org>2001-08-08 17:39:56 +0800
commitbbfda4227e6790fa945368cb5d4cb3d24e4da3d7 (patch)
tree6a451fa92a651f0750f0001e49d8b38a28c90e96
parente835aa2faf3bf45c930924aaa60a134cdd269c35 (diff)
downloadgsoc2013-evolution-bbfda4227e6790fa945368cb5d4cb3d24e4da3d7.tar
gsoc2013-evolution-bbfda4227e6790fa945368cb5d4cb3d24e4da3d7.tar.gz
gsoc2013-evolution-bbfda4227e6790fa945368cb5d4cb3d24e4da3d7.tar.bz2
gsoc2013-evolution-bbfda4227e6790fa945368cb5d4cb3d24e4da3d7.tar.lz
gsoc2013-evolution-bbfda4227e6790fa945368cb5d4cb3d24e4da3d7.tar.xz
gsoc2013-evolution-bbfda4227e6790fa945368cb5d4cb3d24e4da3d7.tar.zst
gsoc2013-evolution-bbfda4227e6790fa945368cb5d4cb3d24e4da3d7.zip
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
-rw-r--r--filter/ChangeLog23
-rw-r--r--filter/filter-context.c3
-rw-r--r--filter/filter-element.c2
-rw-r--r--filter/filter-input.c11
-rw-r--r--filter/filter-option.c14
-rw-r--r--filter/filter-rule.c15
-rw-r--r--filter/rule-context.c51
7 files changed, 82 insertions, 37 deletions
diff --git a/filter/ChangeLog b/filter/ChangeLog
index 3cd961554a..8eeb958271 100644
--- a/filter/ChangeLog
+++ b/filter/ChangeLog
@@ -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
diff --git a/filter/filter-context.c b/filter/filter-context.c
index 18a70abd77..b7a808a764 100644
--- a/filter/filter-context.c
+++ b/filter/filter-context.c
@@ -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);
}
diff --git a/filter/filter-element.c b/filter/filter-element.c
index ea3542b4e2..b7a3b30a05 100644
--- a/filter/filter-element.c
+++ b/filter/filter-element.c
@@ -110,7 +110,7 @@ filter_element_finalise (GtkObject *obj)
{
FilterElement *o = (FilterElement *)obj;
- o = o;
+ g_free(o->name);
((GtkObjectClass *)(parent_class))->finalize(obj);
}
diff --git a/filter/filter-input.c b/filter/filter-input.c
index ee531b9ed0..e25d3e40ee 100644
--- a/filter/filter-input.c
+++ b/filter/filter-input.c
@@ -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 {
diff --git a/filter/filter-option.c b/filter/filter-option.c
index 5167a3df9b..9648bc36a0 100644
--- a/filter/filter-option.c
+++ b/filter/filter-option.c
@@ -113,11 +113,21 @@ filter_option_init (FilterOption *o)
}
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);
}
diff --git a/filter/filter-rule.c b/filter/filter-rule.c
index 038db489c5..9bcbc1c459 100644
--- a/filter/filter-rule.c
+++ b/filter/filter-rule.c
@@ -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;
@@ -113,22 +112,16 @@ filter_rule_init (FilterRule * o)
}
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)
{
FilterRule *o = (FilterRule *) 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);
}
diff --git a/filter/rule-context.c b/filter/rule-context.c
index f24e9948be..b77d5646c9 100644
--- a/filter/rule-context.c
+++ b/filter/rule-context.c
@@ -103,37 +103,46 @@ rule_context_init(RuleContext * o)
}
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;