X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fcoroutine%2Ftest%2Fapi-2.c;h=4da0292f20284d995ce6786742de4a738c72bda0;hp=3564e0df790d8c84bcdc03f9dab43fafd722e9a8;hb=b4f0767d388c7f3629666400f48ede1a7b4be7f5;hpb=fe3995b4e626466ab211e37392f8500f1fffb5c7 diff --git a/ccan/coroutine/test/api-2.c b/ccan/coroutine/test/api-2.c index 3564e0df..4da0292f 100644 --- a/ccan/coroutine/test/api-2.c +++ b/ccan/coroutine/test/api-2.c @@ -59,20 +59,13 @@ static void f2(void *p) static void test1(size_t bufsz) { - void *buf1, *buf2; struct coroutine_stack *stack1, *stack2; - buf1 = malloc(bufsz); - ok1(buf1 != NULL); - stack1 = coroutine_stack_init(buf1, bufsz, 0); - diag("buf1=%p stack1=%p bufsz=0x%zx overhead=0x%zx\n", - buf1, stack1, bufsz, COROUTINE_STK_OVERHEAD); + stack1 = coroutine_stack_alloc(bufsz, 0); ok1(coroutine_stack_check(stack1, NULL) == stack1); ok1(coroutine_stack_size(stack1) == bufsz - COROUTINE_STK_OVERHEAD); - buf2 = malloc(bufsz); - ok1(buf2 != NULL); - stack2 = coroutine_stack_init(buf2, bufsz, 0); + stack2 = coroutine_stack_alloc(bufsz, 0); ok1(coroutine_stack_check(stack2, NULL) == stack2); ok1(coroutine_stack_size(stack2) == bufsz - COROUTINE_STK_OVERHEAD); @@ -90,18 +83,14 @@ static void test1(size_t bufsz) ok(1, "Completed test1"); coroutine_stack_release(stack1, 0); - ok1(coroutine_stack_check(stack1, NULL) == NULL); - free(buf1); coroutine_stack_release(stack2, 0); - ok1(coroutine_stack_check(stack2, NULL) == NULL); - free(buf2); } int main(void) { /* This is how many tests you plan to run */ - plan_tests(14); + plan_tests(10); test1(8192);