more idiomatic c
This commit is contained in:
parent
96e16b96c9
commit
84d79573da
1 changed files with 5 additions and 8 deletions
13
kalloc.c
13
kalloc.c
|
@ -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){
|
||||||
|
|
Loading…
Reference in a new issue