static GHashTable* pattern;
static GHashTable* keys;
static GHashTable* urlcache;
-static gchar* blockcss = NULL;
-static gchar* blockcssprivate = NULL;
+static GString* blockcss;
+static GString* blockcssprivate;
static gchar* blockscript = NULL;
#ifdef G_ENABLE_DEBUG
static guint debug;
urlcache = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify)g_free,
(GDestroyNotify)g_free);
- katze_assign (blockcss, g_strdup ("z-non-exist"));
- katze_assign (blockcssprivate, g_strdup (""));
+ if (blockcss && blockcss->len > 0)
+ g_string_free (blockcss, TRUE);
+ if (blockcssprivate && blockcssprivate->len > 0)
+ g_string_free (blockcssprivate, TRUE);
+ blockcss = g_string_new ("z-non-exist");
+ blockcssprivate = g_string_new ("");
}
#if WEBKIT_CHECK_VERSION (1, 1, 2)
return;
adblock_parse_file (path);
- katze_assign (blockscript, adblock_build_js (blockcss, blockcssprivate));
+ katze_assign (blockscript, adblock_build_js (blockcss->str, blockcssprivate->str));
g_free (path);
/* g_object_unref (download); */
}
}
g_strfreev (filters);
- katze_assign (blockscript, adblock_build_js (blockcss, blockcssprivate));
+ katze_assign (blockscript, adblock_build_js (blockcss->str, blockcssprivate->str));
}
static void
static void
adblock_frame_add (gchar* line)
{
- gchar* new_blockcss;
+ const gchar* separator = " , ";
(void)*line++;
(void)*line++;
{
return;
}
- new_blockcss = g_strdup_printf ("%s, %s", blockcss, line);
- katze_assign (blockcss, new_blockcss);
+ g_string_append (blockcss, separator);
+ g_string_append (blockcss, line);
}
static void
adblock_frame_add_private (const gchar* line,
const gchar* sep)
{
- gchar* new_blockcss;
gchar** data;
data = g_strsplit (line, sep, 2);
domains = g_strsplit (data[0], ",", -1);
for (i = 0; domains[i]; i++)
{
- new_blockcss = g_strdup_printf ("%s;\nsites['%s']+=',%s'",
- blockcssprivate, g_strstrip (domains[i]), data[1]);
- katze_assign (blockcssprivate, new_blockcss);
+ g_string_append_printf (blockcssprivate, ";sites['%s']+=',%s'",
+ g_strstrip (domains[i]), data[1]);
}
g_strfreev (domains);
}
else
{
- new_blockcss = g_strdup_printf ("%s;\nsites['%s']+=',%s'",
- blockcssprivate, data[0], data[1]);
- katze_assign (blockcssprivate, new_blockcss);
+ g_string_append_printf (blockcssprivate, ";sites['%s']+=',%s'",
+ data[0], data[1]);
}
g_strfreev (data);
}
browser, adblock_add_tab_cb, extension);
midori_browser_foreach (browser, (GtkCallback)adblock_deactivate_tabs, browser);
- katze_assign (blockcss, NULL);
- katze_assign (blockcssprivate, NULL);
+ if (blockcss)
+ g_string_free (blockcss, TRUE);
+ if (blockcssprivate)
+ g_string_free (blockcssprivate, TRUE);
+ blockcssprivate = blockcss = NULL;
g_hash_table_destroy (pattern);
g_hash_table_destroy (urlcache);
}