aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--lib/widgets/ephy-location-entry.c37
2 files changed, 24 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index 47d427609..452a9695a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2004-10-27 Christian Persch <chpe@cvs.gnome.org>
+ * lib/widgets/ephy-location-entry.c: (completion_func):
+
+ Avoid strdups in entry completion func. Patch by Peter Harvey.
+
+2004-10-27 Christian Persch <chpe@cvs.gnome.org>
+
* src/bookmarks/ephy-bookmark-action.c: (create_tool_item),
(ephy_bookmark_action_sync_label), (connect_proxy),
(bookmark_changed_cb):
diff --git a/lib/widgets/ephy-location-entry.c b/lib/widgets/ephy-location-entry.c
index 2ff40840d..6a491b82d 100644
--- a/lib/widgets/ephy-location-entry.c
+++ b/lib/widgets/ephy-location-entry.c
@@ -54,15 +54,19 @@ struct _EphyLocationEntryPrivate
guint relevance_col;
};
-static char *web_prefixes [] =
+static const struct
{
- "http://www.",
- "http://",
- "https://www.",
- "https://",
- "www."
+ const char *prefix;
+ int len;
+}
+web_prefixes [] =
+{
+ { "http://www.", 11 },
+ { "http://", 7 },
+ { "https://www.", 12 },
+ { "https://", 8 },
+ { "www.", 4 }
};
-static int n_web_prefixes = G_N_ELEMENTS (web_prefixes);
static void ephy_location_entry_class_init (EphyLocationEntryClass *klass);
static void ephy_location_entry_init (EphyLocationEntry *le);
@@ -236,7 +240,7 @@ completion_func (GtkEntryCompletion *completion,
GtkTreeIter *iter,
gpointer data)
{
- int i;
+ int i, len_key, len_prefix;
char *item = NULL;
char *keywords = NULL;
gboolean ret = FALSE;
@@ -250,7 +254,8 @@ completion_func (GtkEntryCompletion *completion,
le->priv->keywords_col, &keywords,
-1);
- if (!strncmp (key, item, strlen (key)))
+ len_key = strlen (key);
+ if (!strncmp (key, item, len_key))
{
ret = TRUE;
}
@@ -260,21 +265,15 @@ completion_func (GtkEntryCompletion *completion,
}
else
{
- for (i = 0; i < n_web_prefixes; i++)
+ for (i = 0; i < G_N_ELEMENTS (web_prefixes); i++)
{
- char *key_prefixed;
-
- key_prefixed = g_strconcat (web_prefixes[i], key, NULL);
-
- if (!strncmp (key_prefixed, item, strlen (key_prefixed)))
+ len_prefix = web_prefixes[i].len;
+ if (!strncmp (web_prefixes[i].prefix, item, len_prefix) &&
+ !strncmp (key, item + len_prefix, len_key))
{
- g_free (key_prefixed);
-
ret = TRUE;
break;
}
-
- g_free (key_prefixed);
}
}