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
|
||||
growproc(int n)
|
||||
{
|
||||
char *newmem, *oldmem;
|
||||
char *newmem;
|
||||
|
||||
newmem = kalloc(cp->sz + n);
|
||||
if(newmem == 0)
|
||||
return -1;
|
||||
memmove(newmem, cp->mem, cp->sz);
|
||||
memset(newmem + cp->sz, 0, n);
|
||||
oldmem = cp->mem;
|
||||
kfree(cp->mem, cp->sz);
|
||||
cp->mem = newmem;
|
||||
kfree(oldmem, cp->sz);
|
||||
cp->sz += n;
|
||||
setupsegs(cp);
|
||||
return cp->sz - n;
|
||||
|
|
Loading…
Reference in a new issue