simplify growproc
This commit is contained in:
parent
98754d687e
commit
ee3f75f229
1 changed files with 2 additions and 3 deletions
5
proc.c
5
proc.c
|
@ -49,16 +49,15 @@ allocproc(void)
|
||||||
int
|
int
|
||||||
growproc(int n)
|
growproc(int n)
|
||||||
{
|
{
|
||||||
char *newmem, *oldmem;
|
char *newmem;
|
||||||
|
|
||||||
newmem = kalloc(cp->sz + n);
|
newmem = kalloc(cp->sz + n);
|
||||||
if(newmem == 0)
|
if(newmem == 0)
|
||||||
return -1;
|
return -1;
|
||||||
memmove(newmem, cp->mem, cp->sz);
|
memmove(newmem, cp->mem, cp->sz);
|
||||||
memset(newmem + cp->sz, 0, n);
|
memset(newmem + cp->sz, 0, n);
|
||||||
oldmem = cp->mem;
|
kfree(cp->mem, cp->sz);
|
||||||
cp->mem = newmem;
|
cp->mem = newmem;
|
||||||
kfree(oldmem, cp->sz);
|
|
||||||
cp->sz += n;
|
cp->sz += n;
|
||||||
setupsegs(cp);
|
setupsegs(cp);
|
||||||
return cp->sz - n;
|
return cp->sz - n;
|
||||||
|
|
Loading…
Reference in a new issue