Changeset 3cdd6d2


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.
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • buddylist.c

    rd191f45 r3cdd6d2  
    134134void owl_buddylist_cleanup(owl_buddylist *bl)
    135135{
    136   g_ptr_array_foreach(bl->buddies, (GFunc)owl_buddy_delete, NULL);
    137   g_ptr_array_free(bl->buddies, true);
     136  owl_ptr_array_free(bl->buddies, (GDestroyNotify)owl_buddy_delete);
    138137}
  • functions.c

    re4524da r3cdd6d2  
    27792779
    27802780  owl_function_punt(argv->len, (const char *const*) argv->pdata, direction);
    2781   g_ptr_array_foreach(argv, (GFunc)g_free, NULL);
    2782   g_ptr_array_free(argv, true);
     2781  owl_ptr_array_free(argv, g_free);
    27832782}
    27842783
     
    30733072        }
    30743073      }
    3075       g_ptr_array_foreach(anyone, (GFunc)g_free, NULL);
    3076       g_ptr_array_free(anyone, true);
     3074      owl_ptr_array_free(anyone, g_free);
    30773075    }
    30783076  }
     
    34183416  }
    34193417
    3420   g_ptr_array_foreach(anyone, (GFunc)g_free, NULL);
    3421   g_ptr_array_free(anyone, true);
     3418  owl_ptr_array_free(anyone, g_free);
    34223419#endif
    34233420}
  • keymap.c

    re4d7cb6 r3cdd6d2  
    2424  g_free(km->name);
    2525  g_free(km->desc);
    26   g_ptr_array_foreach(km->bindings, (GFunc)owl_keybinding_delete, NULL);
    27   g_ptr_array_free(km->bindings, true);
     26  owl_ptr_array_free(km->bindings, (GDestroyNotify)owl_keybinding_delete);
    2827}
    2928
  • 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);
  • zwrite.c

    r12294d2 r3cdd6d2  
    348348void owl_zwrite_cleanup(owl_zwrite *z)
    349349{
    350   g_ptr_array_foreach(z->recips, (GFunc)g_free, NULL);
    351   g_ptr_array_free(z->recips, true);
     350  owl_ptr_array_free(z->recips, g_free);
    352351  g_free(z->cmd);
    353352  g_free(z->zwriteline);
Note: See TracChangeset for help on using the changeset viewer.