simplify growproc

This commit is contained in:
rtm 2008-08-28 17:57:47 +00:00
parent 98754d687e
commit ee3f75f229

5
proc.c
View file

@ -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;