diff options
author | Miles Bader <miles@gnu.org> | 1997-02-12 17:23:13 +0000 |
---|---|---|
committer | Miles Bader <miles@gnu.org> | 1997-02-12 17:23:13 +0000 |
commit | 90cec78b40ba0f409d109c2af3a2a9062663d015 (patch) | |
tree | e21310819d372773005d2a45f8ff5357bce2570f /libpager/pagemap.c | |
parent | 0840d0299b8511f70bfb3515da2d46bf86180a49 (diff) |
(_pager_pagemap_resize):
Return errors.
Diffstat (limited to 'libpager/pagemap.c')
-rw-r--r-- | libpager/pagemap.c | 36 |
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; } |