Changeset e56303f


Ignore:
Timestamp:
Mar 24, 2011, 4:00:33 PM (10 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, 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.
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • cmd.c

    r3472845 re56303f  
    8585  char **argv;
    8686  int argc;
    87   char *tmpbuff;
    8887  char *retval = NULL;
    8988
    90   tmpbuff=g_strdup(cmdbuff);
    91   argv=owl_parseline(tmpbuff, &argc);
    92   if (argc < 0) {
    93     g_free(tmpbuff);
     89  argv = owl_parseline(cmdbuff, &argc);
     90  if (argv == NULL) {
    9491    owl_function_makemsg("Unbalanced quotes");
    9592    return NULL;
     
    9794 
    9895  if (argc < 1) {
    99     owl_parse_delete(argv, argc);
    100     g_free(tmpbuff);
     96    g_strfreev(argv);
    10197    return NULL;
    10298  }
     
    104100  retval = _owl_cmddict_execute(cd, ctx, strs(argv), argc, cmdbuff);
    105101
    106   owl_parse_delete(argv, argc);
    107   g_free(tmpbuff);
     102  g_strfreev(argv);
    108103  return retval;
    109104}
  • filter.c

    rd4927a7 re56303f  
    1010  argv = owl_parseline(string, &argc);
    1111  f = owl_filter_new(name, argc, strs(argv));
    12   owl_parse_delete(argv, argc);
     12  g_strfreev(argv);
    1313
    1414  return f;
  • tester.c

    r42ee1be re56303f  
    188188      FAIL_UNLESS(desc " - parsed",                     \
    189189                  !strcmp(__argv[0], unquoted));        \
    190       owl_parse_delete(__argv, __argc);                 \
     190      g_strfreev(__argv);                               \
    191191      g_free(__quoted);                         \
    192192    } while (0)
  • 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  }
  • zwrite.c

    r3472845 re56303f  
    123123  }
    124124
    125   owl_parse_delete(argv, argc);
     125  g_strfreev(argv);
    126126
    127127  if (badargs) {
Note: See TracChangeset for help on using the changeset viewer.