From 37254316e0b1c3b0c067cf1962d0882d70a38c12 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 12 Feb 2011 13:43:32 +0100 Subject: * methods/rred.cc: - read patch into MMap only if we work on uncompressed patches --- methods/rred.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'methods/rred.cc') diff --git a/methods/rred.cc b/methods/rred.cc index 1a18a381c..80cd14986 100644 --- a/methods/rred.cc +++ b/methods/rred.cc @@ -252,13 +252,15 @@ struct EdCommand { /*{{{*/ RredMethod::State RredMethod::patchMMap(FileFd &Patch, FileFd &From, /*{{{*/ FileFd &out_file, Hashes *hash) const { #ifdef _POSIX_MAPPED_FILES - MMap ed_cmds(Patch, MMap::ReadOnly); + MMap ed_cmds(MMap::ReadOnly); if (Patch.gzFd() != NULL) { unsigned long mapSize = Patch.Size(); DynamicMMap dyn(0, mapSize, 0); gzread(Patch.gzFd(), dyn.Data(), mapSize); ed_cmds = dyn; - } + } else + ed_cmds = MMap(Patch, MMap::ReadOnly); + MMap in_file(From, MMap::ReadOnly); if (ed_cmds.Size() == 0 || in_file.Size() == 0) -- cgit v1.2.3 From 005428387832e79e314bb8f2605f7e6c69708d14 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 13 Feb 2011 11:37:22 +0100 Subject: update size of dynamic MMap as we write in from the outside --- methods/rred.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'methods/rred.cc') diff --git a/methods/rred.cc b/methods/rred.cc index 80cd14986..9ad0e4464 100644 --- a/methods/rred.cc +++ b/methods/rred.cc @@ -255,9 +255,14 @@ RredMethod::State RredMethod::patchMMap(FileFd &Patch, FileFd &From, /*{{{*/ MMap ed_cmds(MMap::ReadOnly); if (Patch.gzFd() != NULL) { unsigned long mapSize = Patch.Size(); - DynamicMMap dyn(0, mapSize, 0); - gzread(Patch.gzFd(), dyn.Data(), mapSize); - ed_cmds = dyn; + DynamicMMap* dyn = new DynamicMMap(0, mapSize, 0); + if (dyn->Data() == 0) { + delete dyn; + return MMAP_FAILED; + } + dyn->AddSize(mapSize); + gzread(Patch.gzFd(), dyn->Data(), mapSize); + ed_cmds = *dyn; } else ed_cmds = MMap(Patch, MMap::ReadOnly); -- cgit v1.2.3