Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/browser-plugin/glue.cpp
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marcopg@litl.com>2009-03-16 15:47:17 (GMT)
committer Marco Pesenti Gritti <marcopg@litl.com>2010-07-27 22:04:20 (GMT)
commit6831f5f82bcb55340452cbc8a419beae9a47af73 (patch)
treedb3f9c3a31cfb639d216dc9cc7cc699689000958 /browser-plugin/glue.cpp
parent106e1e4bf32d6f48db7347ea12b3468e7a7ca941 (diff)
Do not leak the mime description
Diffstat (limited to 'browser-plugin/glue.cpp')
-rw-r--r--browser-plugin/glue.cpp29
1 files changed, 19 insertions, 10 deletions
diff --git a/browser-plugin/glue.cpp b/browser-plugin/glue.cpp
index 148f566..986cae8 100644
--- a/browser-plugin/glue.cpp
+++ b/browser-plugin/glue.cpp
@@ -34,26 +34,32 @@
NPNetscapeFuncs NPNFuncs;
+static char *mimeDescription = NULL;
+
char *
NP_GetMIMEDescription (void)
{
ev_init ();
- GString *desc = g_string_new (NULL);
- GList *all_types = ev_backends_manager_get_all_types_info ();
+ if (mimeDescription == NULL) {
+ GString *desc = g_string_new (NULL);
+ GList *all_types = ev_backends_manager_get_all_types_info ();
- for (GList *l = all_types; l; l = g_list_next (l)){
- EvTypeInfo *info = (EvTypeInfo *)l->data;
- const char *mime;
- int i = 0;
+ for (GList *l = all_types; l; l = g_list_next (l)){
+ EvTypeInfo *info = (EvTypeInfo *)l->data;
+ const char *mime;
+ int i = 0;
- while ((mime = info->mime_types[i++])) {
- g_string_append_printf (desc, "%s:%s:;",
- mime, info->desc);
+ while ((mime = info->mime_types[i++])) {
+ g_string_append_printf (
+ desc, "%s:%s:;", mime, info->desc);
+ }
}
+
+ mimeDescription = g_string_free (desc, FALSE);
}
- return g_string_free (desc, FALSE);
+ return mimeDescription;
}
NPError
@@ -114,6 +120,9 @@ NP_Initialize (NPNetscapeFuncs *aNPNFuncs, NPPluginFuncs *aNPPFuncs)
NPError
NP_Shutdown (void)
{
+ g_free(mimeDescription);
+ mimeDescription = NULL;
+
return NPERR_NO_ERROR;
}