Changeset d3941a0 for global.c


Ignore:
Timestamp:
Feb 4, 2011, 3:49:44 PM (11 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.8, release-1.9
Children:
65c753e
Parents:
b03c714
git-author:
David Benjamin <davidben@mit.edu> (01/24/11 17:14:08)
git-committer:
David Benjamin <davidben@mit.edu> (02/04/11 15:49:44)
Message:
Use g_strjoinv in owl_global_set_startupargs

It's much nicer than dealing with string lengths, although it does mean
we lose const-correctness because glib just gives up on that with lists
of strings. Also make a copy of the argument list because getopt_long
messes around with argument lists anyway.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • global.c

    r5f8ec6b rd3941a0  
    527527/* startup args */
    528528
    529 void owl_global_set_startupargs(owl_global *g, int argc, const char *const *argv) {
    530   int i, len;
    531 
     529void owl_global_set_startupargs(owl_global *g, int argc, char **argv) {
    532530  if (g->startupargs) owl_free(g->startupargs);
    533  
    534   len=0;
    535   for (i=0; i<argc; i++) {
    536     len+=strlen(argv[i])+5;
    537   }
    538   g->startupargs=owl_malloc(len+5);
    539 
    540   strcpy(g->startupargs, "");
    541   for (i=0; i<argc; i++) {
    542     sprintf(g->startupargs + strlen(g->startupargs), "%s ", argv[i]);
    543   }
    544   g->startupargs[strlen(g->startupargs)-1]='\0';
     531  g->startupargs = g_strjoinv(" ", argv);
    545532}
    546533
Note: See TracChangeset for help on using the changeset viewer.