Changeset 4d86e06 for dict.c


Ignore:
Timestamp:
Jul 23, 2009, 12:53:57 AM (12 years ago)
Author:
Anders Kaseorg <andersk@mit.edu>
Branches:
master, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
ba6c8bd
Parents:
029a8b5
Message:
Get rid of a whole bunch of useless casts.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
File:
1 edited

Legend:

Unmodified
Added
Removed
  • dict.c

    rd43edd2 r4d86e06  
    1818int owl_dict_create(owl_dict *d) {
    1919  d->size=0;
    20   d->els=(owl_dict_el *)owl_malloc(INITSIZE*sizeof(owl_dict_el));
     20  d->els=owl_malloc(INITSIZE*sizeof(owl_dict_el));
    2121  d->avail=INITSIZE;
    2222  if (d->els==NULL) return(-1);
     
    6161  for (i=0; i<d->size; i++) {
    6262    if ((dupk = owl_strdup(d->els[i].k)) == NULL) return(-1);
    63     owl_list_append_element(l, (void*)dupk);
     63    owl_list_append_element(l, dupk);
    6464  }
    6565  return(0);
     
    9595    if (pos!=d->size) {
    9696      /* shift forward to leave us a slot */
    97       memmove((void*)(d->els+pos+1), (void*)(d->els+pos),
     97      memmove(d->els+pos+1, d->els+pos,
    9898              sizeof(owl_dict_el)*(d->size-pos));
    9999    }
     
    152152  printf("# BEGIN testing owl_dict\n");
    153153  FAIL_UNLESS("create", 0==owl_dict_create(&d));
    154   FAIL_UNLESS("insert b", 0==owl_dict_insert_element(&d, "b", (void*)bv, owl_dict_noop_free));
    155   FAIL_UNLESS("insert d", 0==owl_dict_insert_element(&d, "d", (void*)dv, owl_dict_noop_free));
    156   FAIL_UNLESS("insert a", 0==owl_dict_insert_element(&d, "a", (void*)av, owl_dict_noop_free));
    157   FAIL_UNLESS("insert c", 0==owl_dict_insert_element(&d, "c", (void*)cv, owl_dict_noop_free));
    158   FAIL_UNLESS("reinsert d (no replace)", -2==owl_dict_insert_element(&d, "d", (void*)dv, 0));
    159   FAIL_UNLESS("find a", (void*)av==owl_dict_find_element(&d, "a"));
    160   FAIL_UNLESS("find b", (void*)bv==owl_dict_find_element(&d, "b"));
    161   FAIL_UNLESS("find c", (void*)cv==owl_dict_find_element(&d, "c"));
    162   FAIL_UNLESS("find d", (void*)dv==owl_dict_find_element(&d, "d"));
     154  FAIL_UNLESS("insert b", 0==owl_dict_insert_element(&d, "b", bv, owl_dict_noop_free));
     155  FAIL_UNLESS("insert d", 0==owl_dict_insert_element(&d, "d", dv, owl_dict_noop_free));
     156  FAIL_UNLESS("insert a", 0==owl_dict_insert_element(&d, "a", av, owl_dict_noop_free));
     157  FAIL_UNLESS("insert c", 0==owl_dict_insert_element(&d, "c", cv, owl_dict_noop_free));
     158  FAIL_UNLESS("reinsert d (no replace)", -2==owl_dict_insert_element(&d, "d", dv, 0));
     159  FAIL_UNLESS("find a", av==owl_dict_find_element(&d, "a"));
     160  FAIL_UNLESS("find b", bv==owl_dict_find_element(&d, "b"));
     161  FAIL_UNLESS("find c", cv==owl_dict_find_element(&d, "c"));
     162  FAIL_UNLESS("find d", dv==owl_dict_find_element(&d, "d"));
    163163  FAIL_UNLESS("find e (non-existent)", NULL==owl_dict_find_element(&d, "e"));
    164   FAIL_UNLESS("remove d", (void*)dv==owl_dict_remove_element(&d, "d"));
     164  FAIL_UNLESS("remove d", dv==owl_dict_remove_element(&d, "d"));
    165165  FAIL_UNLESS("find d (post-removal)", NULL==owl_dict_find_element(&d, "d"));
    166166
Note: See TracChangeset for help on using the changeset viewer.