From 84d79573da7d701b0bbed92eb874bfd8c2610f75 Mon Sep 17 00:00:00 2001 From: rsc Date: Sun, 16 Jul 2006 16:05:37 +0000 Subject: [PATCH] more idiomatic c --- kalloc.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/kalloc.c b/kalloc.c index cc5791d..068fd43 100644 --- a/kalloc.c +++ b/kalloc.c @@ -31,7 +31,7 @@ void ktest(); * after _end. */ void -kinit() +kinit(void) { extern int end; unsigned mem; @@ -102,7 +102,7 @@ kfree(char *cp, int len) * returns a kernel-segment pointer. * returns 0 if there's no run that's big enough. */ -char * +char* kalloc(int n) { struct run **rr; @@ -133,7 +133,7 @@ kalloc(int n) } void -ktest() +ktest(void) { char *p1, *p2, *p3; @@ -158,11 +158,8 @@ ktest() // test running out of memory p1 = 0; - while(1){ - p2 = kalloc(PAGE); - if(p2 == 0) - break; - *(char **)p2 = p1; + while((p2 = kalloc(PAGE)) != 0){ + *(char**)p2 = p1; p1 = p2; } while(p1){