Changeset 23fddad for functions.c


Ignore:
Timestamp:
Oct 23, 2009, 11:01:30 PM (12 years ago)
Author:
Karl Ramm <kcr@1ts.org>
Branches:
master, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
8590774
Parents:
52761cc
git-author:
Karl Ramm <kcr@1ts.org> (09/30/09 10:12:27)
git-committer:
Karl Ramm <kcr@1ts.org> (10/23/09 23:01:30)
Message:
refactor & rename filter creation & storage management

filter_init_fromstring -> filter_new_fromstring
filter_init -> filter_new
filter_free -> filter_delete

Every time owl_filter_init and owl_filter_init_fromstring were called,
there was a call to malloc right above them;  Conversely, after every
owl_filter_free there needed to be a call to owl_free (and sometimes
there wasn't).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    r52761cc r23fddad  
    21332133  owl_filter *f;
    21342134  const owl_view *v;
    2135   int ret, inuse=0;
     2135  int inuse = 0;
    21362136
    21372137  if (argc < 2) {
     
    21832183
    21842184  /* create the filter and check for errors */
    2185   f=owl_malloc(sizeof(owl_filter));
    2186   ret=owl_filter_init(f, argv[1], argc-2, argv+2);
    2187   if (ret==-1) {
    2188     owl_free(f);
     2185  f = owl_filter_new(argv[1], argc-2, argv+2);
     2186  if (f == NULL) {
    21892187    owl_function_error("Invalid filter");
    21902188    return;
     
    23822380  if (tmpinstance) owl_free(tmpinstance);
    23832381
    2384   f=owl_malloc(sizeof(owl_filter));
    2385   owl_filter_init_fromstring(f, filtname, argbuff);
     2382  f = owl_filter_new_fromstring(filtname, argbuff);
    23862383
    23872384  /* add it to the global list */
     
    24212418
    24222419  /* create the new-internal filter */
    2423   f=owl_malloc(sizeof(owl_filter));
    2424 
    24252420  esclonguser = owl_text_quote(longuser, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    24262421
     
    24302425      esclonguser);
    24312426
    2432   owl_filter_init_fromstring(f, filtname, argbuff);
     2427  f = owl_filter_new_fromstring(filtname, argbuff);
    24332428
    24342429  /* add it to the global list */
     
    24652460
    24662461  /* create the new-internal filter */
    2467   f=owl_malloc(sizeof(owl_filter));
    2468 
    24692462  escuser = owl_text_quote(user, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    24702463
     
    24742467      escuser, owl_global_get_aim_screenname_for_filters(&g));
    24752468
    2476   owl_filter_init_fromstring(f, filtname, argbuff);
     2469  f = owl_filter_new_fromstring(filtname, argbuff);
    24772470
    24782471  /* add it to the global list */
     
    25062499  argbuff = owl_sprintf("type ^%s$", esctype);
    25072500
    2508   owl_filter_init_fromstring(f, filtname, argbuff);
     2501  f = owl_filter_new_fromstring(filtname, argbuff);
    25092502
    25102503  /* add it to the global list */
     
    28252818  owl_filter *f;
    28262819  owl_list *fl;
    2827   int ret, i, j;
     2820  int i, j;
    28282821  fl=owl_global_get_puntlist(&g);
    28292822
    28302823  /* first, create the filter */
    2831   f=owl_malloc(sizeof(owl_filter));
    2832 
    28332824  owl_function_debugmsg("About to filter %s", filter);
    2834   ret=owl_filter_init_fromstring(f, "punt-filter", filter);
    2835   if (ret) {
     2825  f = owl_filter_new_fromstring("punt-filter", filter);
     2826  if (f == NULL) {
    28362827    owl_function_error("Error creating filter for zpunt");
    2837     owl_filter_free(f);
    2838     owl_free(f);
    28392828    return;
    28402829  }
     
    28472836      /* if we're punting, then just silently bow out on this duplicate */
    28482837      if (direction==0) {
    2849         owl_filter_free(f);
    2850         owl_free(f);
     2838        owl_filter_delete(f);
    28512839        return;
    28522840      }
     
    28542842      /* if we're unpunting, then remove this filter from the puntlist */
    28552843      if (direction==1) {
    2856         owl_filter_free(owl_list_get_element(fl, i));
     2844        owl_filter_delete(owl_list_get_element(fl, i));
    28572845        owl_list_remove_element(fl, i);
    2858         owl_filter_free(f);
    2859         owl_free(f);
     2846        owl_filter_delete(f);
    28602847        return;
    28612848      }
Note: See TracChangeset for help on using the changeset viewer.