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
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("");
19
GdkPixbufFormat *format;
21
- fitem = gdk_pixbuf_get_formats();
22
+ list = fitem = gdk_pixbuf_get_formats();
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) ? ":" : "",
38
@@ -125,6 +132,8 @@ gchar **plugin_extensions(G3DContext *context)
40
retval = g_strsplit(extensions, ":", 0);
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)
55
+void ldraw_color_cleanup(LDrawLibrary *lib)
59
+ g_hash_table_destroy(lib->colordb);
61
+ plist = lib->colorlist;
64
+ g3d_material_free((G3DMaterial *)plist->data);
65
+ plist = plist->next;
67
+ g_slist_free(lib->colorlist);
70
G3DMaterial *ldraw_color_lookup(LDrawLibrary *lib, guint32 colid)
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
78
#include "imp_ldraw_types.h"
80
gboolean ldraw_color_init(LDrawLibrary *lib);
81
+void ldraw_color_cleanup(LDrawLibrary *lib);
82
G3DMaterial *ldraw_color_lookup(LDrawLibrary *lib, guint32 colid);
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);
92
g_hash_table_destroy(lib->partdb);
93
+ ldraw_color_cleanup(lib);
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) {
109
@@ -180,6 +181,7 @@ gboolean plugin_load_model_from_stream(G3DContext *context, G3DStream *stream,
111
g_warning("error: face before object");
117
diff --git a/src/material.c b/src/material.c
118
index ad03d62b8bc355ad213d7404c16328f9625a4f1e..e9f529ee606ae7e4dfeab69546d1ca37a465f4dc 100644
121
@@ -36,5 +36,6 @@ G3DMaterial *g3d_material_new(void)
123
void g3d_material_free(G3DMaterial *material)
125
+ g_free(material->name);
128
diff --git a/src/object.c b/src/object.c
129
index 202fbfa58151eaff1493984b900b822760fa87ae..42afe7cc4f3e34424b3e44fb2516f85107fb581e 100644
132
@@ -44,6 +44,7 @@ void g3d_object_free(G3DObject *object)
135
mat = (G3DMaterial*)slist->data;
136
+ g3d_material_free(mat);
138
g_slist_free_1(slist);
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);
145
+ if(object->_tex_images != NULL) g_free(object->_tex_images);
146
+ if(object->_tex_coords != NULL) g3d_vector_free(object->_tex_coords);
150
diff --git a/src/plugins.c b/src/plugins.c
151
index f8d282ba28519e84cbcab97f38b94634d93c6a72..044950df7296bd9c470c610df43a98ac1650462b 100644
156
static void plugins_free_plugin(G3DPlugin *plugin)
159
- g_free(plugin->name);
161
- g_free(plugin->path);
162
- if(plugin->extensions)
163
- g_strfreev(plugin->extensions);
167
+ g_free(plugin->name);
168
+ g_free(plugin->path);
169
+ g_strfreev(plugin->extensions);
171
g_module_close(plugin->module);