multi-cmd: use GSList instead of GList
authorSébastien Marie <semarie@users.noreply.github.com>
Tue, 21 Oct 2014 06:14:38 +0000 (08:14 +0200)
committerSébastien Marie <semarie@users.noreply.github.com>
Tue, 21 Oct 2014 06:35:17 +0000 (08:35 +0200)
the argument building (at launch time) is not optimal, as arguments are
appended (instead of prepended). But as it is a one shot per instance,
and there should not have lot of --cmd passed, it should be tolerable.

src/main.c
src/main.h

index f6e8357..0c44154 100644 (file)
@@ -216,7 +216,7 @@ gboolean vb_load_uri(const Arg *arg)
         char ** cmd = g_malloc_n(3
                 + (vb.embed ? 2 : 0)
                 + (vb.config.file ? 2 : 0)
-                + g_list_length(vb.config.autocmd) * 2
+                + g_slist_length(vb.config.autocmd) * 2
                 , sizeof(char *));
 
         /* build commandline */
@@ -231,7 +231,7 @@ gboolean vb_load_uri(const Arg *arg)
             cmd[i++] = "-c";
             cmd[i++] = vb.config.file;
         }
-        for (GList *l = vb.config.autocmd; l; l = l->next) {
+        for (GSList *l = vb.config.autocmd; l; l = l->next) {
             cmd[i++] = "-C";
             cmd[i++] = l->data;
         }
@@ -428,7 +428,7 @@ void vb_quit(gboolean force)
     autocmd_cleanup();
 #endif
 
-    g_list_free_full(vb.config.autocmd, g_free);
+    g_slist_free_full(vb.config.autocmd, g_free);
 
     for (int i = 0; i < FILES_LAST; i++) {
         g_free(vb.files[i]);
@@ -1486,7 +1486,7 @@ static void read_from_stdin(void)
 
 static gboolean autocmdOptionArgFunc(const gchar *option_name, const gchar *value, gpointer data, GError **error)
 {
-    vb.config.autocmd = g_list_append(vb.config.autocmd, g_strdup(value));
+    vb.config.autocmd = g_slist_append(vb.config.autocmd, g_strdup(value));
     return TRUE;
 }
 
@@ -1532,7 +1532,7 @@ int main(int argc, char *argv[])
     init_core();
 
     /* process the --cmd if this was given */
-    for (GList *l = vb.config.autocmd; l; l = l->next) {
+    for (GSList *l = vb.config.autocmd; l; l = l->next) {
         ex_run_string(l->data);
     }
 
index 6db48cf..860f532 100644 (file)
@@ -320,7 +320,7 @@ typedef struct {
     char         *nextpattern;    /* regex patter nfor prev link matching */
     char         *prevpattern;    /* regex patter nfor next link matching */
     char         *file;           /* path to the custome config file */
-    GList        *autocmd;        /* list of commands given by --cmd option */
+    GSList       *autocmd;        /* list of commands given by --cmd option */
     char         *cafile;         /* path to the ca file */
     GTlsDatabase *tls_db;         /* tls database */
     float        default_zoom;    /* default zoomlevel that is applied on zz zoom reset */