Changeset a1074de


Ignore:
Timestamp:
Mar 7, 2010, 10:26:09 PM (15 years ago)
Author:
Anders Kaseorg <andersk@mit.edu>
Branches:
master, release-1.10, release-1.6, release-1.7, release-1.8, release-1.9
Children:
bf7aa1d
Parents:
0e57335
git-author:
Anders Kaseorg <andersk@mit.edu> (02/27/10 22:21:53)
git-committer:
Anders Kaseorg <andersk@mit.edu> (03/07/10 22:26:09)
Message:
owl_dict_insert_element: Rename free_on_replace argument to delete_on_replace.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Reviewed-by: Nelson Elhage <nelhage@mit.edu>
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • dict.c

    r0f15f12 ra1074de  
    7171}
    7272
    73 void owl_dict_noop_free(void *x) {
     73void owl_dict_noop_delete(void *x)
     74{
    7475  return;
    7576}
     
    7778/* Returns 0 on success.  Will copy the key but make
    7879   a reference to the value.  Will clobber an existing
    79    entry with the same key iff free_on_replace!=NULL,
    80    and will run free_on_replace on the old element.
     80   entry with the same key iff delete_on_replace!=NULL,
     81   and will run delete_on_replace on the old element.
    8182   Will return -2 if replace=NULL and match was found.
    8283*/
    83 int owl_dict_insert_element(owl_dict *d, const char *k, void *v, void (*free_on_replace)(void *old)) {
     84int owl_dict_insert_element(owl_dict *d, const char *k, void *v, void (*delete_on_replace)(void *old))
     85{
    8486  int pos, found;
    8587  char *dupk;
    8688  found = _owl_dict_find_pos(d, k, &pos);
    87   if (found && free_on_replace) {
    88     free_on_replace(d->els[pos].v);
     89  if (found && delete_on_replace) {
     90    delete_on_replace(d->els[pos].v);
    8991    d->els[pos].v = v;
    9092    return(0);
    91   } else if (found && !free_on_replace) {
     93  } else if (found && !delete_on_replace) {
    9294    return(-2);
    9395  } else {
  • filterelement.c

    r27f6487 ra1074de  
    292292  owl_dict_create(&filters);
    293293
    294   owl_dict_insert_element(&filters, f->name, &fe_visiting, owl_dict_noop_free);
     294  owl_dict_insert_element(&filters, f->name, &fe_visiting, owl_dict_noop_delete);
    295295
    296296  rv = _owl_filterelement_is_toodeep(fe, &filters);
     
    311311    } else if (nval == NULL) {
    312312      f = owl_global_get_filter(&g, fe->field);
    313       owl_dict_insert_element(seen, fe->field, &fe_visiting, owl_dict_noop_free);
     313      owl_dict_insert_element(seen, fe->field, &fe_visiting, owl_dict_noop_delete);
    314314      if(f) rv = _owl_filterelement_is_toodeep(f->root, seen);
    315       owl_dict_insert_element(seen, fe->field, &fe_visited, owl_dict_noop_free);
     315      owl_dict_insert_element(seen, fe->field, &fe_visited, owl_dict_noop_delete);
    316316    }
    317317  } else {
  • tester.c

    r8c59178 ra1074de  
    113113  printf("# BEGIN testing owl_dict\n");
    114114  FAIL_UNLESS("create", 0==owl_dict_create(&d));
    115   FAIL_UNLESS("insert b", 0==owl_dict_insert_element(&d, "b", bv, owl_dict_noop_free));
    116   FAIL_UNLESS("insert d", 0==owl_dict_insert_element(&d, "d", dv, owl_dict_noop_free));
    117   FAIL_UNLESS("insert a", 0==owl_dict_insert_element(&d, "a", av, owl_dict_noop_free));
    118   FAIL_UNLESS("insert c", 0==owl_dict_insert_element(&d, "c", cv, owl_dict_noop_free));
     115  FAIL_UNLESS("insert b", 0==owl_dict_insert_element(&d, "b", bv, owl_dict_noop_delete));
     116  FAIL_UNLESS("insert d", 0==owl_dict_insert_element(&d, "d", dv, owl_dict_noop_delete));
     117  FAIL_UNLESS("insert a", 0==owl_dict_insert_element(&d, "a", av, owl_dict_noop_delete));
     118  FAIL_UNLESS("insert c", 0==owl_dict_insert_element(&d, "c", cv, owl_dict_noop_delete));
    119119  FAIL_UNLESS("reinsert d (no replace)", -2==owl_dict_insert_element(&d, "d", dv, 0));
    120120  FAIL_UNLESS("find a", av==owl_dict_find_element(&d, "a"));
Note: See TracChangeset for help on using the changeset viewer.