Changeset e6d7e4e


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:
ecffae6
Parents:
eb897c6
git-author:
David Benjamin <davidben@mit.edu> (03/11/11 11:39:41)
git-committer:
David Benjamin <davidben@mit.edu> (06/25/11 03:26:15)
Message:
Replace the puntlist with an GPtrArray
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    r6829afc re6d7e4e  
    24672467void owl_command_punt_unpunt(int argc, const char *const * argv, const char *buff, int unpunt)
    24682468{
    2469   owl_list * fl;
    2470   owl_filter * f;
     2469  GPtrArray * fl;
    24712470  int i;
    24722471
     
    24782477    if(unpunt && (i=atoi(argv[1])) !=0) {
    24792478      i--;      /* Accept 1-based indexing */
    2480       if(i < owl_list_get_size(fl)) {
    2481         f = owl_list_get_element(fl, i);
    2482         owl_list_remove_element(fl, i);
    2483         owl_filter_delete(f);
     2479      if (i < fl->len) {
     2480        owl_filter_delete(g_ptr_array_remove_index(fl, i));
    24842481        return;
    24852482      } else {
  • functions.c

    r6829afc re6d7e4e  
    22152215{
    22162216  const owl_filter *f;
    2217   const owl_list *fl;
     2217  const GPtrArray *fl;
    22182218  char *tmp;
    22192219  owl_fmtext fm;
    2220   int i, j;
     2220  int i;
    22212221
    22222222  owl_fmtext_init_null(&fm);
    22232223
    22242224  fl=owl_global_get_puntlist(&g);
    2225   j=owl_list_get_size(fl);
    22262225  owl_fmtext_append_bold(&fm, "Active zpunt filters:\n");
    22272226
    2228   for (i=0; i<j; i++) {
    2229     f=owl_list_get_element(fl, i);
     2227  for (i = 0; i < fl->len; i++) {
     2228    f = fl->pdata[i];
    22302229    owl_fmtext_appendf_normal(&fm, "[% 2d] ", i+1);
    22312230    tmp = owl_filter_print(f);
     
    27872786{
    27882787  owl_filter *f;
    2789   owl_list *fl;
    2790   int i, j;
     2788  GPtrArray *fl;
     2789  int i;
    27912790  fl=owl_global_get_puntlist(&g);
    27922791
     
    27992798
    28002799  /* Check for an identical filter */
    2801   j=owl_list_get_size(fl);
    2802   for (i=0; i<j; i++) {
    2803     if (owl_filter_equiv(f, owl_list_get_element(fl, i))) {
     2800  for (i = 0; i < fl->len; i++) {
     2801    if (owl_filter_equiv(f, fl->pdata[i])) {
    28042802      owl_function_debugmsg("found an equivalent punt filter");
    28052803      /* if we're punting, then just silently bow out on this duplicate */
     
    28112809      /* if we're unpunting, then remove this filter from the puntlist */
    28122810      if (direction==1) {
    2813         owl_filter_delete(owl_list_get_element(fl, i));
    2814         owl_list_remove_element(fl, i);
     2811        owl_filter_delete(g_ptr_array_remove_index(fl, i));
    28152812        owl_filter_delete(f);
    28162813        return;
     
    28222819    owl_function_debugmsg("punting");
    28232820    /* If we're punting, add the filter to the global punt list */
    2824     owl_list_append_element(fl, f);
     2821    g_ptr_array_add(fl, f);
    28252822  } else if (direction == 1) {
    28262823    owl_function_makemsg("No matching punt filter");
  • global.c

    r6829afc re6d7e4e  
    4747  owl_dict_create(&(g->filters));
    4848  g->filterlist = NULL;
    49   owl_list_create(&(g->puntlist));
     49  g->puntlist = g_ptr_array_new();
    5050  g->messagequeue = g_queue_new();
    5151  owl_dict_create(&(g->styledict));
     
    579579/* puntlist */
    580580
    581 owl_list *owl_global_get_puntlist(owl_global *g) {
    582   return(&(g->puntlist));
     581GPtrArray *owl_global_get_puntlist(owl_global *g) {
     582  return g->puntlist;
    583583}
    584584
    585585int owl_global_message_is_puntable(owl_global *g, const owl_message *m) {
    586   const owl_list *pl;
    587   int i, j;
    588 
    589   pl=owl_global_get_puntlist(g);
    590   j=owl_list_get_size(pl);
    591   for (i=0; i<j; i++) {
    592     if (owl_filter_message_match(owl_list_get_element(pl, i), m)) return(1);
    593   }
    594   return(0);
     586  const GPtrArray *pl;
     587  int i;
     588
     589  pl = owl_global_get_puntlist(g);
     590  for (i = 0; i < pl->len; i++) {
     591    if (owl_filter_message_match(pl->pdata[i], m)) return 1;
     592  }
     593  return 0;
    595594}
    596595
  • owl.h

    reb897c6 re6d7e4e  
    542542  owl_dict filters;
    543543  GList *filterlist;
    544   owl_list puntlist;
     544  GPtrArray *puntlist;
    545545  owl_vardict vars;
    546546  owl_cmddict cmds;
Note: See TracChangeset for help on using the changeset viewer.