~vibhavp/ubuntu/raring/libg3d/add-autopkgtest

« back to all changes in this revision

Viewing changes to debian/patches/fix-memory-leaks-2.patch

  • Committer: Bazaar Package Importer
  • Author(s): Sven Eckelmann
  • Date: 2010-06-28 23:51:12 UTC
  • Revision ID: james.westby@ubuntu.com-20100628235112-lykpvnz82k8kh7ms
Tags: 0.0.8-10
* debian/patches:
  - Add fix-memory-leaks-2.patch, Fix memory leaks (Closes: #570084)
    Thanks Picca Frederic-Emmanuel <picca@synchrotron-soleil.fr>
  - Add pc-glib2-private.patch, Only require glib2.0 for header files when
    using pkg-config
* Remove outdated README.source
* debian/rules:
  - Enable parallel builds using dh's --parallel
  - Inform about missing installed files using dh's --list-missing
* Upgraded to policy 3.9.0, no changes required

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Description: Fix memory leaks
 
2
Forwarded: https://mail.gna.org/public/libg3d-devel/2010-02/msg00000.html
 
3
Author: Picca Frédéric-Emmanuel <picca@synchrotron-soleil.fr>
 
4
Bug-Debian: http://bugs.debian.org/570084
 
5
 
 
6
---
 
7
diff --git a/plugins/image/img_gdkpixbuf.c b/plugins/image/img_gdkpixbuf.c
 
8
index 931c9fdf9c19059bc01570985ee29189e5f2fae0..5a4984d8242c49029fa66e2914623582c9d622a4 100644
 
9
--- a/plugins/image/img_gdkpixbuf.c
 
10
+++ b/plugins/image/img_gdkpixbuf.c
 
11
@@ -108,16 +108,23 @@ gchar **plugin_extensions(G3DContext *context)
 
12
        gchar *extensions = g_strdup("");
 
13
        gchar **retval;
 
14
        gchar *tmp;
 
15
+       gchar *ext;
 
16
+       gchar **exts;
 
17
        GSList *fitem;
 
18
+       GSList *list;
 
19
        GdkPixbufFormat *format;
 
20
 
 
21
-       fitem = gdk_pixbuf_get_formats();
 
22
+       list = fitem = gdk_pixbuf_get_formats();
 
23
        while(fitem)
 
24
        {
 
25
                format = (GdkPixbufFormat *)fitem->data;
 
26
+               exts = gdk_pixbuf_format_get_extensions(format);
 
27
+               ext = g_strjoinv(":", exts);
 
28
                tmp = g_strdup_printf("%s%s%s", extensions,
 
29
-                       strlen(extensions) ? ":" : "",
 
30
-                       g_strjoinv(":", gdk_pixbuf_format_get_extensions(format)));
 
31
+                                     strlen(extensions) ? ":" : "",
 
32
+                                     ext);
 
33
+               g_strfreev(exts);
 
34
+               g_free(ext);
 
35
                g_free(extensions);
 
36
                extensions = tmp;
 
37
                fitem = fitem->next;
 
38
@@ -125,6 +132,8 @@ gchar **plugin_extensions(G3DContext *context)
 
39
 
 
40
        retval = g_strsplit(extensions, ":", 0);
 
41
        g_free(extensions);
 
42
+       g_slist_free(list);
 
43
+
 
44
        return retval;
 
45
 }
 
46
 
 
47
diff --git a/plugins/import/imp_ldraw/imp_ldraw_color.c b/plugins/import/imp_ldraw/imp_ldraw_color.c
 
48
index 269f6c6d6a418b3a68cb474c8092cac427838d39..7623f5edb8747a2840eeb9df7b4337731b160cd7 100644
 
49
--- a/plugins/import/imp_ldraw/imp_ldraw_color.c
 
50
+++ b/plugins/import/imp_ldraw/imp_ldraw_color.c
 
51
@@ -103,6 +103,21 @@ gboolean ldraw_color_init(LDrawLibrary *lib)
 
52
        return TRUE;
 
53
 }
 
54
 
 
55
+void ldraw_color_cleanup(LDrawLibrary *lib)
 
56
+{
 
57
+       GSList *plist;
 
58
+
 
59
+       g_hash_table_destroy(lib->colordb);
 
60
+
 
61
+       plist = lib->colorlist;
 
62
+       while(plist)
 
63
+       {
 
64
+               g3d_material_free((G3DMaterial *)plist->data);
 
65
+               plist = plist->next;
 
66
+       }
 
67
+       g_slist_free(lib->colorlist);
 
68
+}
 
69
+
 
70
 G3DMaterial *ldraw_color_lookup(LDrawLibrary *lib, guint32 colid)
 
71
 {
 
72
        G3DMaterial *material;
 
73
diff --git a/plugins/import/imp_ldraw/imp_ldraw_color.h b/plugins/import/imp_ldraw/imp_ldraw_color.h
 
74
index e5844de6c81b6b61fa88e70a07b15c49af1dfff1..941d0c10db6754018df6212f3a67e21903e1f6d5 100644
 
75
--- a/plugins/import/imp_ldraw/imp_ldraw_color.h
 
76
+++ b/plugins/import/imp_ldraw/imp_ldraw_color.h
 
77
@@ -25,6 +25,7 @@
 
78
 #include "imp_ldraw_types.h"
 
79
 
 
80
 gboolean ldraw_color_init(LDrawLibrary *lib);
 
81
+void ldraw_color_cleanup(LDrawLibrary *lib);
 
82
 G3DMaterial *ldraw_color_lookup(LDrawLibrary *lib, guint32 colid);
 
83
 
 
84
 #endif /* _IMP_LDRAW_COLOR_H */
 
85
diff --git a/plugins/import/imp_ldraw/imp_ldraw_library.c b/plugins/import/imp_ldraw/imp_ldraw_library.c
 
86
index aa07cdb52a45e8a7db380a8bba9ae7ffaf96433f..7e12128e7222eadcf16c952cea6ba0109d90b834 100644
 
87
--- a/plugins/import/imp_ldraw/imp_ldraw_library.c
 
88
+++ b/plugins/import/imp_ldraw/imp_ldraw_library.c
 
89
@@ -114,6 +114,7 @@ void ldraw_library_cleanup(LDrawLibrary *lib)
 
90
                ldraw_part_free(part);
 
91
        }
 
92
        g_hash_table_destroy(lib->partdb);
 
93
+       ldraw_color_cleanup(lib);
 
94
        g_free(lib);
 
95
 }
 
96
 
 
97
diff --git a/plugins/import/imp_obj/imp_obj.c b/plugins/import/imp_obj/imp_obj.c
 
98
index 466754e7a16bc3441cf19b39a88b0fe1f433b3ae..6d7fe2f20dc5adccdfccb163e88170800a6d09c2 100644
 
99
--- a/plugins/import/imp_obj/imp_obj.c
 
100
+++ b/plugins/import/imp_obj/imp_obj.c
 
101
@@ -164,6 +164,7 @@ gboolean plugin_load_model_from_stream(G3DContext *context, G3DStream *stream,
 
102
                                                /* next one if # of vertices < 3 */
 
103
                                                if(face->vertex_count < 3) {
 
104
                                                        g3d_face_free(face);
 
105
+                                                       g_strfreev(vstrs);
 
106
                                                        continue;
 
107
                                                }
 
108
 
 
109
@@ -180,6 +181,7 @@ gboolean plugin_load_model_from_stream(G3DContext *context, G3DStream *stream,
 
110
                                                if(object == NULL) {
 
111
                                                        g_warning("error: face before object");
 
112
                                                        g3d_face_free(face);
 
113
+                                                       g_strfreev(vstrs);
 
114
                                                        return FALSE;
 
115
                                                }
 
116
 
 
117
diff --git a/src/material.c b/src/material.c
 
118
index ad03d62b8bc355ad213d7404c16328f9625a4f1e..e9f529ee606ae7e4dfeab69546d1ca37a465f4dc 100644
 
119
--- a/src/material.c
 
120
+++ b/src/material.c
 
121
@@ -36,5 +36,6 @@ G3DMaterial *g3d_material_new(void)
 
122
 
 
123
 void g3d_material_free(G3DMaterial *material)
 
124
 {
 
125
+       g_free(material->name);
 
126
        g_free(material);
 
127
 }
 
128
diff --git a/src/object.c b/src/object.c
 
129
index 202fbfa58151eaff1493984b900b822760fa87ae..42afe7cc4f3e34424b3e44fb2516f85107fb581e 100644
 
130
--- a/src/object.c
 
131
+++ b/src/object.c
 
132
@@ -44,6 +44,7 @@ void g3d_object_free(G3DObject *object)
 
133
        while(slist != NULL)
 
134
        {
 
135
                mat = (G3DMaterial*)slist->data;
 
136
+               g3d_material_free(mat);
 
137
                snext = slist->next;
 
138
                g_slist_free_1(slist);
 
139
                slist = snext;
 
140
@@ -67,7 +68,8 @@ void g3d_object_free(G3DObject *object)
 
141
        if(object->_indices != NULL) g_free(object->_indices);
 
142
        if(object->_materials != NULL) g_free(object->_materials);
 
143
        if(object->_flags != NULL) g_free(object->_flags);
 
144
-
 
145
+       if(object->_tex_images != NULL) g_free(object->_tex_images);
 
146
+       if(object->_tex_coords != NULL) g3d_vector_free(object->_tex_coords);
 
147
        g_free(object);
 
148
 }
 
149
 
 
150
diff --git a/src/plugins.c b/src/plugins.c
 
151
index f8d282ba28519e84cbcab97f38b94634d93c6a72..044950df7296bd9c470c610df43a98ac1650462b 100644
 
152
--- a/src/plugins.c
 
153
+++ b/src/plugins.c
 
154
@@ -32,13 +32,12 @@
 
155
 
 
156
 static void plugins_free_plugin(G3DPlugin *plugin)
 
157
 {
 
158
-       if(plugin->name)
 
159
-               g_free(plugin->name);
 
160
-       if(plugin->path)
 
161
-               g_free(plugin->path);
 
162
-       if(plugin->extensions)
 
163
-               g_strfreev(plugin->extensions);
 
164
+       if(!plugin)
 
165
+               return;
 
166
 
 
167
+       g_free(plugin->name);
 
168
+       g_free(plugin->path);
 
169
+       g_strfreev(plugin->extensions);
 
170
        if(plugin->module)
 
171
                g_module_close(plugin->module);
 
172