Changeset e56303f for util.c


Ignore:
Timestamp:
Mar 24, 2011, 4:00:33 PM (13 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.10, release-1.8, release-1.9
Children:
f25df21
Parents:
42ee1be
git-author:
David Benjamin <davidben@mit.edu> (03/08/11 14:44:30)
git-committer:
David Benjamin <davidben@mit.edu> (03/24/11 16:00:33)
Message:
Replace owl_parse_delete with g_strfreev

Also cut the pointless g_strdup in owl_cmddict_execute and allow argc to
be NULL if we don't care about the value.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • util.c

    r3472845 re56303f  
    9898}
    9999
    100 void owl_parse_delete(char **argv, int argc)
    101 {
    102   g_strfreev(argv);
    103 }
    104 
     100/* Break a command line up into argv, argc.  The caller must free
     101   the returned values with g_strfreev.  If there is an error argc will be set
     102   to -1, argv will be NULL and the caller does not need to free anything. The
     103   returned vector is NULL-terminated. */
    105104char **owl_parseline(const char *line, int *argc)
    106105{
    107   /* break a command line up into argv, argc.  The caller must free
    108      the returned values.  If there is an error argc will be set to
    109      -1, argv will be NULL and the caller does not need to free
    110      anything. The returned vector is NULL-terminated. */
    111 
    112106  GPtrArray *argv;
    113107  int i, len, between=1;
     
    119113  curarg = g_string_new("");
    120114  quote='\0';
    121   *argc=0;
     115  if (argc) *argc=0;
    122116  for (i=0; i<len+1; i++) {
    123117    /* find the first real character */
     
    170164  }
    171165
    172   *argc = argv->len;
     166  if (argc) *argc = argv->len;
    173167  g_ptr_array_add(argv, NULL);
    174168  g_string_free(curarg, true);
     
    180174    g_ptr_array_foreach(argv, (GFunc)g_free, NULL);
    181175    g_ptr_array_free(argv, true);
    182     *argc = -1;
     176    if (argc) *argc = -1;
    183177    return(NULL);
    184178  }
Note: See TracChangeset for help on using the changeset viewer.