Changeset f25df21


Ignore:
Timestamp:
Mar 24, 2011, 4:05:29 PM (10 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.8, release-1.9
Children:
c809f5e
Parents:
e56303f
git-author:
David Benjamin <davidben@mit.edu> (03/08/11 15:04:52)
git-committer:
David Benjamin <davidben@mit.edu> (03/24/11 16:05:29)
Message:
Don't call owl_list_create in owl_dict_get_keys

Until we get rid of this owl_list thing altogether, there should be a
convention as to who initializes the thing. Otherwise, we leak memory
from people initializing it too many times.

Whoever reviews this probably wants to look over this very carefully in
case I missed one of the owl_list_creates.

Also kill the various wrappers over owl_list_cleanup as they are not the
inverse of any operation.
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • cmd.c

    re56303f rf25df21  
    3333}
    3434
    35 /* free the list with owl_cmddict_namelist_cleanup */
    3635void owl_cmddict_get_names(const owl_cmddict *d, owl_list *l) {
    3736  owl_dict_get_keys(d, l);
     
    4039const owl_cmd *owl_cmddict_find(const owl_cmddict *d, const char *name) {
    4140  return owl_dict_find_element(d, name);
    42 }
    43 
    44 void owl_cmddict_namelist_cleanup(owl_list *l)
    45 {
    46   owl_list_cleanup(l, g_free);
    4741}
    4842
  • dict.c

    rd4927a7 rf25df21  
    5858}
    5959
    60 /* creates a list and fills it in with keys.  duplicates the keys,
     60/* Appends dictionary keys to a list.  Duplicates the keys,
    6161 * so they will need to be freed by the caller. */
    6262int owl_dict_get_keys(const owl_dict *d, owl_list *l) {
    6363  int i;
    6464  char *dupk;
    65   if (owl_list_create(l)) return(-1);
    6665  for (i=0; i<d->size; i++) {
    6766    if ((dupk = g_strdup(d->els[i].k)) == NULL) return(-1);
  • functions.c

    r4479497 rf25df21  
    5353  owl_fmtext_append_bold(&fm, "Commands:  ");
    5454  owl_fmtext_append_normal(&fm, "(use 'show command <name>' for details)\n");
     55  owl_list_create(&l);
    5556  owl_cmddict_get_names(owl_global_get_cmddict(&g), &l);
    5657  owl_fmtext_append_list(&fm, &l, "\n", owl_function_cmd_describe);
    5758  owl_fmtext_append_normal(&fm, "\n");
    5859  owl_function_popless_fmtext(&fm);
    59   owl_cmddict_namelist_cleanup(&l);
     60  owl_list_cleanup(&l, g_free);
    6061  owl_fmtext_cleanup(&fm);
    6162}
     
    8586  owl_fmtext_init_null(&fm);
    8687  owl_fmtext_append_bold(&fm, "Styles:\n");
     88  owl_list_create(&l);
    8789  owl_global_get_style_names(&g, &l);
    8890  owl_fmtext_append_list(&fm, &l, "\n", owl_function_style_describe);
     
    16231625  g_string_append_printf(str, "%-20s = %s\n", "VARIABLE", "VALUE");
    16241626  g_string_append_printf(str, "%-20s   %s\n",  "--------", "-----");
     1627  owl_list_create(&varnames);
    16251628  owl_variable_dict_get_names(owl_global_get_vardict(&g), &varnames);
    16261629  numvarnames = owl_list_get_size(&varnames);
     
    16371640  }
    16381641  g_string_append(str, "\n");
    1639   owl_variable_dict_namelist_cleanup(&varnames);
     1642  owl_list_cleanup(&varnames, g_free);
    16401643
    16411644  owl_function_popless_text(str->str);
     
    16531656  owl_fmtext_append_bold(&fm,
    16541657      "Variables: (use 'show variable <name>' for details)\n");
     1658  owl_list_create(&varnames);
    16551659  owl_variable_dict_get_names(owl_global_get_vardict(&g), &varnames);
    16561660  numvarnames = owl_list_get_size(&varnames);
     
    16611665    }
    16621666  }
    1663   owl_variable_dict_namelist_cleanup(&varnames);
     1667  owl_list_cleanup(&varnames, g_free);
    16641668  owl_function_popless_fmtext(&fm);
    16651669  owl_fmtext_cleanup(&fm);
     
    28742878  owl_fmtext_append_bold(&fm, "Keymaps:   ");
    28752879  owl_fmtext_append_normal(&fm, "(use 'show keymap <name>' for details)\n");
     2880  owl_list_create(&l);
    28762881  owl_keyhandler_get_keymap_names(kh, &l);
    28772882  owl_fmtext_append_list(&fm, &l, "\n", owl_function_keymap_summary);
     
    28882893 
    28892894  owl_function_popless_fmtext(&fm);
    2890   owl_keyhandler_keymap_namelist_cleanup(&l);
     2895  owl_list_cleanup(&l, g_free);
    28912896  owl_fmtext_cleanup(&fm);
    28922897}
  • global.c

    rf54b07d rf25df21  
    764764}
    765765
    766 /* creates a list and fills it in with keys.  duplicates the keys,
    767  * so they will need to be freed by the caller. */
    768766int owl_global_get_style_names(const owl_global *g, owl_list *l) {
    769767  return owl_dict_get_keys(&(g->styledict), l);
  • help.c

    rc38bfe0 rf25df21  
    129129  owl_fmtext_append_bold(&fm,
    130130                         "Variables:\n");
     131  owl_list_create(&varnames);
    131132  owl_variable_dict_get_names(owl_global_get_vardict(&g), &varnames);
    132133  numvarnames = owl_list_get_size(&varnames);
     
    137138    }
    138139  }
    139   owl_variable_dict_namelist_cleanup(&varnames);
     140  owl_list_cleanup(&varnames, g_free);
    140141
    141142  owl_fmtext_append_normal(&fm, "\n");
  • keymap.c

    r3472845 rf25df21  
    217217}
    218218
    219 /* free the list with owl_cmddict_namelist_cleanup */
    220219void owl_keyhandler_get_keymap_names(const owl_keyhandler *kh, owl_list *l)
    221220{
    222221  owl_dict_get_keys(&kh->keymaps, l);
    223222}
    224 
    225 void owl_keyhandler_keymap_namelist_cleanup(owl_list *l)
    226 {
    227   owl_list_cleanup(l, g_free);
    228 }
    229 
    230223
    231224
  • perlconfig.c

    r3472845 rf25df21  
    6363
    6464  /* TODO: add an iterator-like interface to owl_dict */
     65  owl_list_create(&l);
    6566  owl_dict_get_keys(d, &l);
    6667  for (i = 0; i < owl_list_get_size(&l); i++) {
  • perlglue.xs

    rddbbcffa rf25df21  
    389389        {
    390390                kh = owl_global_get_keyhandler(&g);
     391                owl_list_create(&l);
    391392                owl_keyhandler_get_keymap_names(kh, &l);
    392393                RETVAL = owl_new_av(&l, (SV*(*)(const void*))owl_new_sv);
  • tester.c

    re56303f rf25df21  
    248248
    249249  FAIL_UNLESS("get_size", 3==owl_dict_get_size(&d));
     250  owl_list_create(&l);
    250251  FAIL_UNLESS("get_keys", 0==owl_dict_get_keys(&d, &l));
    251252  FAIL_UNLESS("get_keys result size", 3==owl_list_get_size(&l));
  • variable.c

    r010a951 rf25df21  
    632632}
    633633
    634 /* free the list with owl_variable_dict_namelist_cleanup */
    635634void owl_variable_dict_get_names(const owl_vardict *d, owl_list *l) {
    636635  owl_dict_get_keys(d, l);
    637 }
    638 
    639 void owl_variable_dict_namelist_cleanup(owl_list *l)
    640 {
    641   owl_list_cleanup(l, g_free);
    642636}
    643637
Note: See TracChangeset for help on using the changeset viewer.