]> git.saurik.com Git - apt.git/commitdiff
update size of dynamic MMap as we write in from the outside
authorDavid Kalnischkies <kalnischkies@gmail.com>
Sun, 13 Feb 2011 10:37:22 +0000 (11:37 +0100)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Sun, 13 Feb 2011 10:37:22 +0000 (11:37 +0100)
apt-pkg/contrib/mmap.h
debian/changelog
methods/rred.cc

index 5ca951204b393ab5c2b20045035b48bd94a43f04..e9baa93397d1503661a3d3268a7bde1080e1698a 100644 (file)
@@ -61,6 +61,7 @@ class MMap
    inline operator void *() {return Base;};
    inline void *Data() {return Base;}; 
    inline unsigned long Size() {return iSize;};
+   inline void AddSize(unsigned long const size) {iSize += size;};
    
    // File manipulators
    bool Sync();
index f8d29abde6ad625f53143dc8bf2198ec3e63715d..86d31d8564a7c14d6a79b2e39c56d25f893bedaf 100644 (file)
@@ -9,10 +9,11 @@ apt (0.8.12) unstable; urgency=low
       marker could be lost later by the removal of rdepends (Closes: #612557)
   * methods/rred.cc:
     - read patch into MMap only if we work on uncompressed patches
+    - update size of dynamic MMap as we write in from the outside
   * apt-pkg/contrib/mmap.cc:
     - do not try to free the mapping if its is unset
 
- -- David Kalnischkies <kalnischkies@gmail.com>  Sat, 12 Feb 2011 19:39:25 +0100
+ -- David Kalnischkies <kalnischkies@gmail.com>  Sun, 13 Feb 2011 11:36:11 +0100
 
 apt (0.8.11.1) unstable; urgency=low
 
index 80cd14986ea4f4d34317a5732dd1f6992786f228..9ad0e44646db82711c62014ae3a9613fa051c134 100644 (file)
@@ -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);