For the past few days, I've been trying to find and eliminate as many
memory leaks as possible in the Evolution 1.2 calendar. I have CVS diffs
for Evolution, GAL and Bonobo.

The Evo patch is pretty straightforward: One big leak (all property
setters in libical omitted freeing the old value) and several small
ones.

The GAL patch is just two small leaks.

The Bonobo patch potentially fixes a big leak; I'm unsure about the
patch, though. Valgrind reports all widgets in a bonobo-ui-toolbar as
leaked, and if I add the unref, the leak goes away (nothing breaks from
what I can see). The Evo code seems to be doing things right and is not
leaking any references.

I have a similar case in GTK 1.2's GtkInvisible widget, which refs and
sinks itself on creation - it's reported as a leak, although it's being
destroyed in Evo. I'm hoping for some input on the Bonobo patch before I
propose a patch for that, though. [Michael?]
 
-- 
Hans Petter
? autom4te.cache
? evolution-1.2-libical-setter-leak.patch
? patch
? help/C/evolution
? help/C/index.html
? help/C/omf_timestamp
? libical/autom4te.cache
Index: calendar/gui/e-meeting-model.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-meeting-model.c,v
retrieving revision 1.29
diff -u -r1.29 e-meeting-model.c
--- calendar/gui/e-meeting-model.c      26 Sep 2002 16:14:44 -0000      1.29
+++ calendar/gui/e-meeting-model.c      26 Nov 2002 06:06:33 -0000
@@ -409,6 +409,7 @@
        e_meeting_attendee_set_language (ia, g_strdup (e_table_model_value_at (source, 
E_MEETING_MODEL_LANGUAGE_COL, row)));
 
        e_meeting_model_add_attendee (E_MEETING_MODEL (etm), ia);
+       gtk_object_unref (GTK_OBJECT (ia));
 }
 
 static void *
@@ -1821,6 +1822,8 @@
                        process_section (im, destv, roles[i]);
                        e_destination_freev (destv);
                }               
+
+               g_free (string);
        }
 }
 
Index: calendar/gui/itip-utils.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/itip-utils.c,v
retrieving revision 1.59
diff -u -r1.59 itip-utils.c
--- calendar/gui/itip-utils.c   24 Oct 2002 14:25:53 -0000      1.59
+++ calendar/gui/itip-utils.c   26 Nov 2002 06:06:33 -0000
@@ -575,12 +575,15 @@
                 return CORBA_string_dup (U_("Journal information"));
         case CAL_COMPONENT_FREEBUSY:
                 cal_component_get_dtstart (comp, &dt);
-                if (dt.value) {
+                if (dt.value)
                         start = get_label (dt.value);
-                        cal_component_get_dtend (comp, &dt);
-                        if (dt.value)
-                                end = get_label (dt.value);
-                }
+               cal_component_free_datetime (&dt);
+
+               cal_component_get_dtend (comp, &dt);
+               if (dt.value)
+                       end = get_label (dt.value);
+               cal_component_free_datetime (&dt);
+
                 if (start != NULL && end != NULL) {
                         char *tmp, *tmp_utf;
                         tmp = g_strdup_printf (_("Free/Busy information (%s to %s)"), 
start, end);
@@ -1054,8 +1057,10 @@
                CORBA_free (filename);
        if (description != NULL)
                CORBA_free (description);
-       if (attach_data != NULL)
+       if (attach_data != NULL) {
+               CORBA_free (attach_data->_buffer);
                CORBA_free (attach_data);
+       }
 
        return retval;
 }
Index: calendar/gui/dialogs/comp-editor-util.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/dialogs/comp-editor-util.c,v
retrieving revision 1.19
diff -u -r1.19 comp-editor-util.c
--- calendar/gui/dialogs/comp-editor-util.c     10 Jul 2002 21:34:35 -0000      1.19
+++ calendar/gui/dialogs/comp-editor-util.c     26 Nov 2002 06:06:34 -0000
@@ -478,6 +478,8 @@
 #endif
 
        contact_destv = e_destination_importv (contacts_string);
+       g_free (contacts_string);
+
        if (contact_destv) {
                for (i = 0; contact_destv[i] != NULL; i++) {
                        name = e_destination_get_name (contact_destv[i]);
Index: calendar/gui/dialogs/event-editor.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/dialogs/event-editor.c,v
retrieving revision 1.24
diff -u -r1.24 event-editor.c
--- calendar/gui/dialogs/event-editor.c 3 Oct 2002 10:57:22 -0000       1.24
+++ calendar/gui/dialogs/event-editor.c 26 Nov 2002 06:06:34 -0000
@@ -398,6 +398,8 @@
        gtk_object_destroy (GTK_OBJECT (priv->model));
        gtk_object_unref (GTK_OBJECT (priv->model));
 
+       g_free (priv);
+
        if (GTK_OBJECT_CLASS (parent_class)->destroy)
                (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
 }
Index: calendar/gui/dialogs/meeting-page.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/dialogs/meeting-page.c,v
retrieving revision 1.44
diff -u -r1.44 meeting-page.c
--- calendar/gui/dialogs/meeting-page.c 27 Sep 2002 20:23:14 -0000      1.44
+++ calendar/gui/dialogs/meeting-page.c 26 Nov 2002 06:06:34 -0000
@@ -251,7 +251,7 @@
                gtk_object_unref (GTK_OBJECT (priv->comp));
        
        cleanup_attendees (priv->deleted_attendees);
-       g_ptr_array_free (priv->deleted_attendees, FALSE);
+       g_ptr_array_free (priv->deleted_attendees, TRUE);
        
        itip_addresses_free (priv->addresses);
 
Index: libical/scripts/mkderivedparameters.pl
===================================================================
RCS file: /cvs/gnome/libical/scripts/mkderivedparameters.pl,v
retrieving revision 1.6
diff -u -r1.6 mkderivedparameters.pl
--- libical/scripts/mkderivedparameters.pl      17 Apr 2001 17:54:43 -0000      1.6
+++ libical/scripts/mkderivedparameters.pl      26 Nov 2002 06:06:35 -0000
@@ -188,7 +188,9 @@
 
      $charorenum = "    icalerror_check_arg_rz( (param!=0), \"param\");\n    return 
($type)((struct icalparameter_impl*)param)->string;";
     
-     $set_code = "((struct icalparameter_impl*)param)->string = 
icalmemory_strdup(v);";
+     $set_code = "if (((struct icalparameter_impl*)param)->string != 0)\n" .
+                 "      free((void *) ((struct 
+icalparameter_impl*)param)->string);\n" .
+                 "   ((struct icalparameter_impl*)param)->string = 
+icalmemory_strdup(v);";
 
      $pointer_check = "icalerror_check_arg_rz( (v!=0),\"v\");"; 
      $pointer_check_v = "icalerror_check_arg_rv( (v!=0),\"v\");"; 
Index: libical/src/libical/icalperiod.c
===================================================================
RCS file: /cvs/gnome/libical/src/libical/icalperiod.c,v
retrieving revision 1.2
diff -u -r1.2 icalperiod.c
--- libical/src/libical/icalperiod.c    19 Sep 2001 19:34:19 -0000      1.2
+++ libical/src/libical/icalperiod.c    26 Nov 2002 06:06:35 -0000
@@ -137,8 +137,9 @@
 
     icalmemory_append_string(&buf, &buf_ptr, &buf_size, end); 
     
-
-    return buf;
+    buf_ptr = icalmemory_tmp_copy (buf);
+    icalmemory_free_buffer (buf);
+    return buf_ptr;
 }
 
 
? autom4te.cache
Index: gal/e-table/e-table.c
===================================================================
RCS file: /cvs/gnome/gal/gal/e-table/e-table.c,v
retrieving revision 1.208
diff -u -r1.208 e-table.c
--- gal/e-table/e-table.c       19 Sep 2002 18:28:24 -0000      1.208
+++ gal/e-table/e-table.c       26 Nov 2002 06:08:38 -0000
@@ -1310,6 +1310,8 @@
        int i, j;
 
        state = e_table_state_new();
+       if (state->sort_info)
+               gtk_object_unref (GTK_OBJECT (state->sort_info));
        state->sort_info = e_table->sort_info;
        gtk_object_ref(GTK_OBJECT(state->sort_info));
 
Index: gal/widgets/e-canvas-background.c
===================================================================
RCS file: /cvs/gnome/gal/gal/widgets/e-canvas-background.c,v
retrieving revision 1.3
diff -u -r1.3 e-canvas-background.c
--- gal/widgets/e-canvas-background.c   26 Apr 2002 20:11:09 -0000      1.3
+++ gal/widgets/e-canvas-background.c   26 Nov 2002 06:08:38 -0000
@@ -182,6 +182,8 @@
                gdk_bitmap_unref (ecb->priv->stipple);
        ecb->priv->stipple = NULL;
 
+       g_free (ecb->priv);
+
        if (GTK_OBJECT_CLASS (parent_class)->destroy)
                 GTK_OBJECT_CLASS (parent_class)->destroy (object);
 }
? doc/api/bonobo-docs.sgml
? doc/api/bonobo-undocumented.txt
Index: bonobo/bonobo-ui-toolbar.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-ui-toolbar.c,v
retrieving revision 1.44
diff -u -r1.44 bonobo-ui-toolbar.c
--- bonobo/bonobo-ui-toolbar.c  19 Sep 2001 20:35:59 -0000      1.44
+++ bonobo/bonobo-ui-toolbar.c  26 Nov 2002 06:09:29 -0000
@@ -1357,6 +1357,7 @@
        g_assert (GTK_WIDGET (item)->parent == GTK_WIDGET (toolbar));
 
        gtk_widget_queue_resize (GTK_WIDGET (toolbar));
+       gtk_object_unref (GTK_OBJECT (item));
 }
 
 GList *

Reply via email to