From: Cristiano Giuffrida Date: Sat, 20 Dec 2014 23:33:44 +0000 (+0100) Subject: vm: Fix heap preallocation. X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zpipe.c?a=commitdiff_plain;h=refs%2Fchanges%2F11%2F3111%2F1;p=minix.git vm: Fix heap preallocation. Change-Id: I5b7f6473b9bbff69eae6ab26c889ad8ed902ff3a --- diff --git a/minix/servers/vm/rs.c b/minix/servers/vm/rs.c index cde9f89d9..38d56bd25 100644 --- a/minix/servers/vm/rs.c +++ b/minix/servers/vm/rs.c @@ -198,12 +198,17 @@ static int rs_memctl_make_vm_instance(struct vmproc *new_vm_vmp) static int rs_memctl_heap_prealloc(struct vmproc *vmp, vir_bytes *addr, size_t *len) { + struct vir_region *data_vr; + vir_bytes bytes; - /* - * XXX: Is this still needed? - */ + if(*len <= 0) { + return EINVAL; + } + data_vr = region_search(&vmp->vm_regions_avl, VM_MMAPBASE, AVL_LESS); + *addr = data_vr->vaddr + data_vr->length; + bytes = *addr + *len; - return OK; + return real_brk(vmp, bytes); } /*===========================================================================*