summaryrefslogtreecommitdiff
path: root/proc.c
diff options
context:
space:
mode:
authorkaashoek <kaashoek>2006-08-24 02:44:41 +0000
committerkaashoek <kaashoek>2006-08-24 02:44:41 +0000
commitea2909b6b5ceb54383ab23fd195ebae29cfdb7ca (patch)
tree78a7076d23319c0c38b7f62108b6d06908379c42 /proc.c
parent8b58e81077abf4e843873f16c03077e2fafce52d (diff)
downloadxv6-labs-ea2909b6b5ceb54383ab23fd195ebae29cfdb7ca.tar.gz
xv6-labs-ea2909b6b5ceb54383ab23fd195ebae29cfdb7ca.tar.bz2
xv6-labs-ea2909b6b5ceb54383ab23fd195ebae29cfdb7ca.zip
user-level malloc (untested)
nit in sbrk indirect block fix dup to share fd struct
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/proc.c b/proc.c
index 7382add..b65bb70 100644
--- a/proc.c
+++ b/proc.c
@@ -138,22 +138,23 @@ copyproc(struct proc* p)
return np;
}
-int
+char *
growproc(int n)
{
struct proc *cp = curproc[cpu()];
char *newmem, *oldmem;
newmem = kalloc(cp->sz + n);
- if(newmem == 0) return -1;
+ if(newmem == 0) return (char *) -1;
memmove(newmem, cp->mem, cp->sz);
memset(newmem + cp->sz, 0, n);
oldmem = cp->mem;
cp->mem = newmem;
kfree(oldmem, cp->sz);
cp->sz += n;
- cprintf("growproc: added %d bytes\n", n);
- return 0;
+ cprintf("growproc: added %d bytes starting at address 0x%x\n", n,
+ newmem + cp->sz - n);
+ return newmem + cp->sz - n;
}
// Per-CPU process scheduler.