From 344c50cb576d2c3922d90adb8baededc258dd599 Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Sun, 11 Jul 1999 05:30:55 +0000 Subject: 1999-07-09 Thomas Bushnell, BSG * bunzip2.c (bunzip2): Use mmap instead of vm_allocate. * copy.c (copy_read): Likewise. (copy_clone): Likewise. * encode.c (store_encode): Likewise. * gunzip.c (gunzip): Likewise. * rdwr.c (store_read): Likewise. * zero.c (zero_read): Likewise. --- libstore/copy.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'libstore/copy.c') diff --git a/libstore/copy.c b/libstore/copy.c index ded612fe..0c1834fa 100644 --- a/libstore/copy.c +++ b/libstore/copy.c @@ -34,10 +34,9 @@ copy_read (struct store *store, if (*len < amount) /* Have to allocate memory for the return value. */ { - error_t err = - vm_allocate (mach_task_self (), (vm_address_t *)buf, amount, 1); - if (err) - return err; + *buf = mmap (0, amount, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); + if (*buf == (void *)-1)) + return errno; } bcopy (store->hook + (addr * store->block_size), *buf, amount); @@ -124,11 +123,15 @@ copy_cleanup (struct store *store) error_t copy_clone (const struct store *from, struct store *to) { - error_t err = - vm_allocate (mach_task_self (), (vm_address_t *)&to->hook, to->size, 1); - if (! err) - bcopy (from->hook, to->hook, from->size); - return err; + void *buf; + buf = mmap (0, to->size, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); + if (buf != (void *) -1) + { + to->hook = buf; + bcopy (from->hook, to->hook, from->size); + return 0; + } + return errno; } struct store_class -- cgit v1.2.3