From 7dc4f6757170638977d8a0a2fd8ef6fbd4bc7c8d Mon Sep 17 00:00:00 2001 From: salinasv Date: Sun, 17 May 2009 13:55:27 -0500 Subject: Dinamically alloc state strings. --- uzbl.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'uzbl.c') diff --git a/uzbl.c b/uzbl.c index 5f997f7..56822aa 100644 --- a/uzbl.c +++ b/uzbl.c @@ -173,6 +173,7 @@ clean_up(void) { if (uzbl.behave.socket_dir) unlink (uzbl.comm.socket_path); + g_free(uzbl.state.executable_path); g_string_free(uzbl.state.keycmd, TRUE); g_hash_table_destroy(uzbl.bindings); g_hash_table_destroy(uzbl.behave.commands); @@ -215,7 +216,7 @@ create_web_view_cb (WebKitWebView *web_view, WebKitWebFrame *frame, gpointer us (void) web_view; (void) frame; (void) user_data; - if (uzbl.state.selected_url[0]!=0) { + if (uzbl.state.selected_url != NULL) { if (uzbl.state.verbose) printf("\nNew web view -> %s\n",uzbl.state.selected_url); new_window_load_uri(uzbl.state.selected_url); @@ -304,9 +305,10 @@ link_hover_cb (WebKitWebView* page, const gchar* title, const gchar* link, gpoin (void) title; (void) data; //Set selected_url state variable - uzbl.state.selected_url[0] = '\0'; + g_free(uzbl.state.selected_url); + uzbl.state.selected_url = NULL; if (link) { - strcpy (uzbl.state.selected_url, link); + uzbl.state.selected_url = g_strdup(link); } update_title(); } @@ -486,15 +488,17 @@ run_js (WebKitWebView * web_view, const gchar *param) { static void search_text (WebKitWebView *page, const char *param, const gboolean forward) { if ((param) && (param[0] != '\0')) { - strcpy(uzbl.state.searchtx, param); + uzbl.state.searchtx = g_strdup(param); } - if (uzbl.state.searchtx[0] != '\0') { + if (uzbl.state.searchtx != NULL) { if (uzbl.state.verbose) printf ("Searching: %s\n", uzbl.state.searchtx); webkit_web_view_unmark_text_matches (page); webkit_web_view_mark_text_matches (page, uzbl.state.searchtx, FALSE, 0); webkit_web_view_set_highlight_text_matches (page, TRUE); webkit_web_view_search_text (page, uzbl.state.searchtx, FALSE, forward, TRUE); + g_free(uzbl.state.searchtx); + uzbl.state.searchtx = NULL; } } @@ -1657,7 +1661,9 @@ main (int argc, char* argv[]) { if (!g_thread_supported ()) g_thread_init (NULL); - strcpy(uzbl.state.executable_path,argv[0]); + uzbl.state.executable_path = g_strdup(argv[0]); + uzbl.state.selected_url = NULL; + uzbl.state.searchtx = NULL; GOptionContext* context = g_option_context_new ("- some stuff here maybe someday"); g_option_context_add_main_entries (context, entries, NULL); -- cgit v1.2.3