diff options
author | Robert Morris <[email protected]> | 2010-08-10 17:08:41 -0400 |
---|---|---|
committer | Robert Morris <[email protected]> | 2010-08-10 17:08:41 -0400 |
commit | 83d2db91f75460e1275d67847adec0fca5a9800b (patch) | |
tree | cc8df8349ca1981e85d8e343dbf365b59f5eabd7 /proc.c | |
parent | c4cc10da7ef6d65f0f654445e0af35b8309f16c2 (diff) | |
download | xv6-labs-83d2db91f75460e1275d67847adec0fca5a9800b.tar.gz xv6-labs-83d2db91f75460e1275d67847adec0fca5a9800b.tar.bz2 xv6-labs-83d2db91f75460e1275d67847adec0fca5a9800b.zip |
allow sbrk(-x) to de-allocate user memory
Diffstat (limited to 'proc.c')
-rw-r--r-- | proc.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -142,8 +142,13 @@ userinit(void) int growproc(int n) { - if (!allocuvm(proc->pgdir, (char *)proc->sz, n)) - return -1; + if(n > 0){ + if (!allocuvm(proc->pgdir, (char *)proc->sz, n)) + return -1; + } else if(n < 0){ + if (!deallocuvm(proc->pgdir, (char *)(proc->sz + n), 0 - n)) + return -1; + } proc->sz += n; switchuvm(proc); return 0; |