Changed url_history_get_all to add the entries to existing given list.
authorDaniel Carl <danielcarl@gmx.de>
Sat, 9 Mar 2013 00:36:25 +0000 (01:36 +0100)
committerDaniel Carl <danielcarl@gmx.de>
Sat, 9 Mar 2013 00:36:25 +0000 (01:36 +0100)
This will allow us to combine url history and later to implement bookmarks in
a single completion list.

src/completion.c
src/url_history.c
src/url_history.h

index d34410f..b5a1e8b 100644 (file)
@@ -77,14 +77,14 @@ gboolean completion_complete(Client* c, gboolean back)
             c->comps.completions, source, (Comp_Func)g_str_has_prefix, &input[5], ":set "
         );
     } else if (!strncmp(input, ":open ", 6)) {
-        source = url_history_get_all();
+        url_history_get_all(&source);
         c->comps.completions = completion_init_completion(
             c,
             c->comps.completions, source, (Comp_Func)util_strcasestr, &input[6], ":open "
         );
         g_list_free(source);
     } else if (!strncmp(input, ":tabopen ", 9)) {
-        source = url_history_get_all();
+        url_history_get_all(&source);
         c->comps.completions = completion_init_completion(
             c,
             c->comps.completions, source, (Comp_Func)util_strcasestr, &input[9], ":tabopen "
index 1c0f729..a2bc8b3 100644 (file)
@@ -87,19 +87,17 @@ void url_history_add(const char* url, const char* title)
 }
 
 /**
- * Retrieves the ur history as ne allocated list.
+ * Appends the url history entries to given list.
  */
-GList* url_history_get_all(void)
+void url_history_get_all(GList** list)
 {
-    GList* out = NULL;
     for (GList* link = core.behave.url_history; link; link = link->next) {
         UrlHist* hi = (UrlHist*)link->data;
         /* put only the url in the list - do not allocate new memory */
-        out = g_list_prepend(out, hi->uri);
+        *list = g_list_prepend(*list, hi->uri);
     }
 
-    out = g_list_reverse(out);
-    return out;
+    *list = g_list_reverse(*list);
 }
 
 static void url_history_free(UrlHist* item)
index 32bd86a..7e2cabd 100644 (file)
@@ -9,6 +9,6 @@ typedef struct {
 void url_history_init(void);
 void url_history_cleanup(void);
 void url_history_add(const char* url, const char* title);
-GList* url_history_get_all(void);
+void url_history_get_all(GList** list);
 
 #endif /* end of include guard: _URL_HISTORY_H */