Bladeren bron

update size of dynamic MMap as we write in from the outside

David Kalnischkies 15 jaren geleden
bovenliggende
commit
0054283878
3 gewijzigde bestanden met toevoegingen van 11 en 4 verwijderingen
  1. 1 0
      apt-pkg/contrib/mmap.h
  2. 2 1
      debian/changelog
  3. 8 3
      methods/rred.cc

+ 1 - 0
apt-pkg/contrib/mmap.h

@@ -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();

+ 2 - 1
debian/changelog

@@ -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
 

+ 8 - 3
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);