Changeset 3cdd6d2 for util.c


Ignore:
Timestamp:
Jun 25, 2011, 3:26:15 AM (13 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.10, release-1.8, release-1.9
Children:
ce68f23
Parents:
e4524da
git-author:
David Benjamin <davidben@mit.edu> (06/11/11 19:49:43)
git-committer:
David Benjamin <davidben@mit.edu> (06/25/11 03:26:15)
Message:
Add owl_ptr_array_free convenience function

Unfortunately, most uses of GPtrArray here require a two-step chant
which is really annoying. Until we require glib 2.22 and get
g_ptr_array_new_with_free_func, use this helper function.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • util.c

    r6829afc r3cdd6d2  
    9898}
    9999
     100void owl_ptr_array_free(GPtrArray *array, GDestroyNotify element_free_func)
     101{
     102  /* TODO: when we move to requiring glib 2.22+, use
     103   * g_ptr_array_new_with_free_func instead. */
     104  if (element_free_func)
     105    g_ptr_array_foreach(array, (GFunc)element_free_func, NULL);
     106  g_ptr_array_free(array, true);
     107}
     108
    100109/* Break a command line up into argv, argc.  The caller must free
    101110   the returned values with g_strfreev.  If there is an error argc will be set
     
    170179  /* check for unbalanced quotes */
    171180  if (quote!='\0') {
    172     /* TODO: when we move to requiring glib 2.22+, use
    173      * g_ptr_array_new_with_free_func. */
    174     g_ptr_array_foreach(argv, (GFunc)g_free, NULL);
    175     g_ptr_array_free(argv, true);
     181    owl_ptr_array_free(argv, g_free);
    176182    if (argc) *argc = -1;
    177183    return(NULL);
Note: See TracChangeset for help on using the changeset viewer.