summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libpager/pagemap.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/libpager/pagemap.c b/libpager/pagemap.c
index 2adbcc0e..9fefc63f 100644
--- a/libpager/pagemap.c
+++ b/libpager/pagemap.c
@@ -1,5 +1,5 @@
/* Pagemap manipulation for pager library
- Copyright (C) 1994 Free Software Foundation
+ Copyright (C) 1994, 1997 Free Software Foundation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -19,21 +19,27 @@
#include <string.h>
/* Grow the pagemap of pager P as necessary to deal with address OFF */
-void
-_pager_pagemap_resize (struct pager *p,
- vm_address_t off)
+error_t
+_pager_pagemap_resize (struct pager *p, vm_address_t off)
{
- void *newaddr;
- int newsize;
+ error_t err = 0;
off /= __vm_page_size;
- if (p->pagemapsize >= off)
- return;
-
- newsize = round_page (off);
- vm_allocate (mach_task_self (), (u_int *)&newaddr, newsize, 1);
- bcopy (p->pagemap, newaddr, p->pagemapsize);
- vm_deallocate (mach_task_self (), (u_int)p->pagemap, p->pagemapsize);
- p->pagemap = newaddr;
- p->pagemapsize = newsize;
+
+ if (p->pagemapsize < off)
+ {
+ void *newaddr;
+ int newsize = round_page (off);
+
+ err = vm_allocate (mach_task_self (), (u_int *)&newaddr, newsize, 1);
+ if (! err)
+ {
+ bcopy (p->pagemap, newaddr, p->pagemapsize);
+ vm_deallocate (mach_task_self (), (u_int)p->pagemap, p->pagemapsize);
+ p->pagemap = newaddr;
+ p->pagemapsize = newsize;
+ }
+ }
+
+ return err;
}