]> git.saurik.com Git - apt.git/commitdiff
Pass the old map size to ReMap()
authorJulian Andres Klode <jak@debian.org>
Sat, 23 Jan 2016 14:02:48 +0000 (15:02 +0100)
committerJulian Andres Klode <jak@debian.org>
Sat, 23 Jan 2016 14:13:04 +0000 (15:13 +0100)
This allows us to check if a value to be remapped was inside
the cache or not, which will become useful at a later point.

Gbp-Dch: ignore

apt-pkg/pkgcachegen.cc
apt-pkg/pkgcachegen.h

index 43347cf65b910d37a8a325e3d5cdf81861d92f3c..a472babeb9f1e1210aac2b641a7bd895637235cf 100644 (file)
@@ -141,7 +141,7 @@ pkgCacheGenerator::~pkgCacheGenerator()
    Map.Sync(0,sizeof(pkgCache::Header));
 }
                                                                        /*}}}*/
-void pkgCacheGenerator::ReMap(void const * const oldMap, void const * const newMap) {/*{{{*/
+void pkgCacheGenerator::ReMap(void const * const oldMap, void const * const newMap, size_t oldSize) {/*{{{*/
    if (oldMap == newMap)
       return;
 
@@ -181,27 +181,30 @@ void pkgCacheGenerator::ReMap(void const * const oldMap, void const * const newM
 // CacheGenerator::WriteStringInMap                                    /*{{{*/
 map_stringitem_t pkgCacheGenerator::WriteStringInMap(const char *String,
                                        const unsigned long &Len) {
+   size_t oldSize = Map.Size();
    void const * const oldMap = Map.Data();
    map_stringitem_t const index = Map.WriteString(String, Len);
    if (index != 0)
-      ReMap(oldMap, Map.Data());
+      ReMap(oldMap, Map.Data(), oldSize);
    return index;
 }
                                                                        /*}}}*/
 // CacheGenerator::WriteStringInMap                                    /*{{{*/
 map_stringitem_t pkgCacheGenerator::WriteStringInMap(const char *String) {
+   size_t oldSize = Map.Size();
    void const * const oldMap = Map.Data();
    map_stringitem_t const index = Map.WriteString(String);
    if (index != 0)
-      ReMap(oldMap, Map.Data());
+      ReMap(oldMap, Map.Data(), oldSize);
    return index;
 }
                                                                        /*}}}*/
 map_pointer_t pkgCacheGenerator::AllocateInMap(const unsigned long &size) {/*{{{*/
+   size_t oldSize = Map.Size();
    void const * const oldMap = Map.Data();
    map_pointer_t const index = Map.Allocate(size);
    if (index != 0)
-      ReMap(oldMap, Map.Data());
+      ReMap(oldMap, Map.Data(), oldSize);
    return index;
 }
                                                                        /*}}}*/
index d8d1e303aefce6ce8cfb926166f5e20d51a0afe3..ea288ad6e6ae73922d6b9bd9e33c81a0409d4152 100644 (file)
@@ -149,7 +149,7 @@ class APT_HIDDEN pkgCacheGenerator                                  /*{{{*/
                        MMap **OutMap,pkgCache **OutCache, bool AllowMem = false);
    APT_PUBLIC static bool MakeOnlyStatusCache(OpProgress *Progress,DynamicMMap **OutMap);
 
-   void ReMap(void const * const oldMap, void const * const newMap);
+   void ReMap(void const * const oldMap, void const * const newMap, size_t oldSize);
 
    pkgCacheGenerator(DynamicMMap *Map,OpProgress *Progress);
    virtual ~pkgCacheGenerator();