X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fjmap%2Ftest%2Frun-ptridx-type.c;h=20a604a1fcde6f797a30fe1575918a92ba74c17e;hp=83642a8e68c36d7f7623199795e8eea0fe2d6d6c;hb=cc2d609dfca7192305ad477b8c2b52cfdc1aa9be;hpb=4116b284c098f6c67f62d8292e93d8f73d833e9d diff --git a/ccan/jmap/test/run-ptridx-type.c b/ccan/jmap/test/run-ptridx-type.c index 83642a8e..20a604a1 100644 --- a/ccan/jmap/test/run-ptridx-type.c +++ b/ccan/jmap/test/run-ptridx-type.c @@ -17,26 +17,26 @@ static int cmp_ptr(const void *a, const void *b) int main(int argc, char *argv[]) { struct jmap_foo *map; - struct foo *foo[NUM], **foop; - struct idx *idx[NUM], *index; + struct foo *foo[NUM+1], **foop; + struct idx *idx[NUM+1], *index; unsigned int i; plan_tests(25 + NUM*2 + 6); - for (i = 0; i < NUM; i++) + for (i = 0; i < NUM+1; i++) foo[i] = malloc(20); qsort(foo, NUM, sizeof(foo[0]), cmp_ptr); /* idx[i] == foo[i] + 1, for easy checking */ - for (i = 0; i < NUM; i++) + for (i = 0; i < NUM+1; i++) idx[i] = (void *)((char *)foo[i] + 1); map = jmap_foo_new(); ok1(jmap_foo_error(map) == NULL); - ok1(jmap_foo_test(map, idx[i]) == false); - ok1(jmap_foo_get(map, idx[i]) == (struct foo *)NULL); + ok1(jmap_foo_test(map, idx[NUM]) == false); + ok1(jmap_foo_get(map, idx[NUM]) == (struct foo *)NULL); ok1(jmap_foo_count(map) == 0); ok1(jmap_foo_first(map) == (struct idx *)NULL); ok1(jmap_foo_del(map, idx[0]) == false); @@ -97,5 +97,8 @@ int main(int argc, char *argv[]) ok1(jmap_foo_error(map) == NULL); jmap_foo_free(map); + for (i = 0; i < NUM+1; i++) + free(foo[i]); + return exit_status(); }