Added a missing return value in vm_resize_region().

Cleaned the code a bit.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@586 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2002-08-05 05:22:27 +00:00
parent c931f4823d
commit 75faf9fda3
+23 -11
View File
@@ -1573,48 +1573,58 @@ int vm_delete_aspace(aspace_id aid)
return B_NO_ERROR;
}
int vm_resize_region (aspace_id aid, region_id rid, size_t newSize)
int
vm_resize_region(aspace_id aid, region_id rid, size_t newSize)
{
vm_cache_ref *myCacheRef;
vm_region *myRegion,*current;
size_t oldSize;
bool failed = false;
// Steps:
//1) Get the vm_cache_ref for the region
myRegion=vm_get_region_by_id(rid);
myRegion = vm_get_region_by_id(rid);
if (!myRegion)
return B_ERROR;
myCacheRef = myRegion->cache_ref;
// 2) Resize all of the regions from the vm_cache_ref (fix them all and fail if they can't be resized)
oldSize = myRegion->size;
for (current=myCacheRef->region_list;current;current=current->cache_next)
{
if (current->aspace_next->base<=(current->base+newSize))
{
for (current = myCacheRef->region_list;current;current = current->cache_next) {
if (current->aspace_next->base <= (current->base + newSize)) {
failed = true;
break;
}
current->size = newSize;
}
if (failed) // OH NO! Go back and fix all of the broken ones...
{
if (failed) { // OH NO! Go back and fix all of the broken ones...
for (current = myCacheRef->region_list;current;current = current->cache_next)
current->size = oldSize;
return B_ERROR;
}
// 3) Update the vm_cache size
myCacheRef->cache->virtual_size = newSize;
return 0;
}
int vm_aspace_walk_start(struct hash_iterator *i)
int
vm_aspace_walk_start(struct hash_iterator *i)
{
hash_open(aspace_table, i);
return 0;
}
vm_address_space *vm_aspace_walk_next(struct hash_iterator *i)
vm_address_space *
vm_aspace_walk_next(struct hash_iterator *i)
{
vm_address_space *aspace;
@@ -1626,7 +1636,9 @@ vm_address_space *vm_aspace_walk_next(struct hash_iterator *i)
return aspace;
}
static int vm_thread_dump_max_commit(void *unused)
static int
vm_thread_dump_max_commit(void *unused)
{
int oldmax = -1;