more idiomatic c

This commit is contained in:
rsc 2006-07-16 16:05:37 +00:00
parent 96e16b96c9
commit 84d79573da

View file

@ -31,7 +31,7 @@ void ktest();
* after _end. * after _end.
*/ */
void void
kinit() kinit(void)
{ {
extern int end; extern int end;
unsigned mem; unsigned mem;
@ -102,7 +102,7 @@ kfree(char *cp, int len)
* returns a kernel-segment pointer. * returns a kernel-segment pointer.
* returns 0 if there's no run that's big enough. * returns 0 if there's no run that's big enough.
*/ */
char * char*
kalloc(int n) kalloc(int n)
{ {
struct run **rr; struct run **rr;
@ -133,7 +133,7 @@ kalloc(int n)
} }
void void
ktest() ktest(void)
{ {
char *p1, *p2, *p3; char *p1, *p2, *p3;
@ -158,11 +158,8 @@ ktest()
// test running out of memory // test running out of memory
p1 = 0; p1 = 0;
while(1){ while((p2 = kalloc(PAGE)) != 0){
p2 = kalloc(PAGE); *(char**)p2 = p1;
if(p2 == 0)
break;
*(char **)p2 = p1;
p1 = p2; p1 = p2;
} }
while(p1){ while(p1){