diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2004-10-27 20:44:52 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2004-10-27 20:44:52 +0800 |
commit | 6e074fb3eb0f51be6ca04c440d7435b965312d89 (patch) | |
tree | c791cd346bf23c33705b6a8684b92bca4b48a522 | |
parent | 86c2f402bbc078f538bccce5b2c52546fb7a185a (diff) | |
download | gsoc2013-epiphany-6e074fb3eb0f51be6ca04c440d7435b965312d89.tar gsoc2013-epiphany-6e074fb3eb0f51be6ca04c440d7435b965312d89.tar.gz gsoc2013-epiphany-6e074fb3eb0f51be6ca04c440d7435b965312d89.tar.bz2 gsoc2013-epiphany-6e074fb3eb0f51be6ca04c440d7435b965312d89.tar.lz gsoc2013-epiphany-6e074fb3eb0f51be6ca04c440d7435b965312d89.tar.xz gsoc2013-epiphany-6e074fb3eb0f51be6ca04c440d7435b965312d89.tar.zst gsoc2013-epiphany-6e074fb3eb0f51be6ca04c440d7435b965312d89.zip |
Avoid strdups in entry completion func. Patch by Peter Harvey.
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.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | lib/widgets/ephy-location-entry.c | 37 |
2 files changed, 24 insertions, 19 deletions
@@ -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); } } |