- Timestamp:
- Jul 23, 2009, 12:53:57 AM (15 years ago)
- Branches:
- master, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- ba6c8bd
- Parents:
- 029a8b5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
dict.c
rd43edd2 r4d86e06 18 18 int owl_dict_create(owl_dict *d) { 19 19 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)); 21 21 d->avail=INITSIZE; 22 22 if (d->els==NULL) return(-1); … … 61 61 for (i=0; i<d->size; i++) { 62 62 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); 64 64 } 65 65 return(0); … … 95 95 if (pos!=d->size) { 96 96 /* 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, 98 98 sizeof(owl_dict_el)*(d->size-pos)); 99 99 } … … 152 152 printf("# BEGIN testing owl_dict\n"); 153 153 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")); 163 163 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")); 165 165 FAIL_UNLESS("find d (post-removal)", NULL==owl_dict_find_element(&d, "d")); 166 166
Note: See TracChangeset
for help on using the changeset viewer.