[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

PoC-patch for 'apt without MMap'



Hello.

For anyone interested in review/testing/comments: find 'nommap-v1' proof-of-concept patch
in attachment.

This patch is built on top of my 'debian-experimental-jackyf' branch, which can be found
at 'bzr+ssh://jackyf-devel@bazaar.launchpad.net/%7Ejackyf-devel/apt/debian-experimental/'
address.

Regards,
-- 
Eugene V. Lyubimkin aka JackYF, JID: jackyf.devel(maildog)gmail.com
Ukrainian C++ developer, Debian APT contributor
=== modified file 'apt-inst/deb/dpkgdb.cc'
--- apt-inst/deb/dpkgdb.cc	2008-11-20 21:08:09 +0000
+++ apt-inst/deb/dpkgdb.cc	2008-11-29 21:56:31 +0000
@@ -72,7 +72,7 @@
 // DpkgDB::debDpkgDB - Constructor					/*{{{*/
 // ---------------------------------------------------------------------
 /* */
-debDpkgDB::debDpkgDB() : CacheMap(0), FileMap(0)
+debDpkgDB::debDpkgDB()
 {
    AdminDir = flNotFile(_config->Find("Dir::State::status"));   
    DiverInode = 0;
@@ -86,13 +86,9 @@
 {
    delete Cache;
    Cache = 0;
-   delete CacheMap;
-   CacheMap = 0;
    
    delete FList;
    FList = 0;
-   delete FileMap;
-   FileMap = 0;
 }
 									/*}}}*/
 // DpkgDB::InitMetaTmp - Get the temp dir for meta information		/*{{{*/
@@ -130,19 +126,15 @@
    directory, but there is no clear way on how to do that yet. */
 bool debDpkgDB::ReadyPkgCache(OpProgress &Progress)
 {
-   if (Cache != 0)
+   pkgCache* PkgCache = &Cache->GetCache();
+   if (PkgCache != 0)
    {  
       Progress.OverallProgress(1,1,1,_("Reading package lists"));      
       return true;
    }
    
-   if (CacheMap != 0)
-   {
-      delete CacheMap;
-      CacheMap = 0;
-   }
-   
-   if (pkgMakeOnlyStatusCache(Progress,&CacheMap) == false)
+   PkgCache = new pkgCache;
+   if (pkgMakeOnlyStatusCache(*PkgCache, Progress) == false)
       return false;
    Cache->DropProgress();
    
@@ -256,7 +248,7 @@
 	 if (End - Start > 1)
 	 {
 	    pkgFLCache::NodeIterator Node = FList->GetNode(Start,End,
- 					      FlPkg.Offset(),true,false);
+ 					      FlPkg,true,false);
 	    if (Node.end() == true)
 	    {
 	       _error->Error(_("Internal error getting a node"));
@@ -384,16 +376,13 @@
    }
    
    // Create the cache and read in the file listing
-   FileMap = new DynamicMMap(MMap::Public);
-   FList = new pkgFLCache(*FileMap);
+   FList = new pkgFLCache();
    if (_error->PendingError() == true || 
        ReadFList(Progress) == false ||
        ReadConfFiles() == false || 
        ReadDiversions() == false)
    {
       delete FList;
-      delete FileMap;
-      FileMap = 0;
       FList = 0;
       return false;
    }
@@ -402,7 +391,6 @@
    cout << "Dir: " << FList->HeaderP->DirCount << endl;
    cout << "Package: " << FList->HeaderP->PackageCount << endl;
    cout << "HashSize: " << FList->HeaderP->HashSize << endl;
-   cout << "Size: " << FileMap->Size() << endl;
    cout << endl;
 
    return true;

=== modified file 'apt-inst/deb/dpkgdb.h'
--- apt-inst/deb/dpkgdb.h	2008-11-20 21:08:09 +0000
+++ apt-inst/deb/dpkgdb.h	2008-11-23 12:03:54 +0000
@@ -27,8 +27,6 @@
    protected:
    
    string AdminDir;
-   DynamicMMap *CacheMap;
-   DynamicMMap *FileMap;
    unsigned long DiverInode;
    signed long DiverTime;
    

=== modified file 'apt-inst/extract.cc'
--- apt-inst/extract.cc	2008-11-20 21:08:09 +0000
+++ apt-inst/extract.cc	2008-11-23 12:03:39 +0000
@@ -47,6 +47,7 @@
 #include <apt-inst/extract.h>
 #include <apt-pkg/contrib/error.h>
 #include <apt-pkg/deb/debversion.h>
+#include <apt-pkg/contrib/fileutl.h>
 
 #include <sys/stat.h>
 #include <stdio.h>
@@ -102,7 +103,7 @@
    pkgFLCache::NodeIterator RealNde = Nde;
       
    // See if the file is already in the file listing
-   unsigned long FileGroup = RealNde->File;
+   char* FileGroup = RealNde->File;
    for (; RealNde.end() == false && FileGroup == RealNde->File; RealNde++)
       if (RealNde.RealPackage() == FLPkg)
 	 break;
@@ -110,7 +111,7 @@
    // Nope, create an entry
    if (RealNde.end() == true)
    {
-      RealNde = FLCache.GetNode(Itm.Name,End,FLPkg.Offset(),true,false);
+      RealNde = FLCache.GetNode(Itm.Name,End,FLPkg,true,false);
       if (RealNde.end() == true)
 	 return false;
       RealNde->Flags |= pkgFLCache::Node::NewFile;
@@ -145,7 +146,7 @@
 			      "diversion target %s/%s"),Nde.DirN(),Nde.File());
       
       // See if it is us and we are following it in the right direction
-      if (Div->OwnerPkg != FLPkg.Offset() && Div.DivertFrom() == Nde)
+      if (Div->OwnerPkg != FLPkg && Div.DivertFrom() == Nde)
       {
 	 Nde = Div.DivertTo();
 	 End = FileName + snprintf(FileName,sizeof(FileName)-20,"%s/%s",
@@ -267,7 +268,7 @@
       clog << "Aborted, backing out" << endl;
    
    pkgFLCache::NodeIterator Files = FLPkg.Files();
-   map_ptrloc *Last = &FLPkg->Files;
+   pkgFLCache::Node** Last = &FLPkg->Files;
    
    /* Loop over all files, restore those that have been unpacked from their
       dpkg-tmp entires */
@@ -289,7 +290,7 @@
 	 pkgFLCache::DiverIterator Div = Nde.Diversion();
 	 
 	 // See if it is us and we are following it in the right direction
-	 if (Div->OwnerPkg != FLPkg.Offset() && Div.DivertFrom() == Nde)
+	 if (Div->OwnerPkg != FLPkg && Div.DivertFrom() == Nde)
 	 {
 	    Nde = Div.DivertTo();
 	    if (snprintf(FileName,sizeof(FileName)-20,"%s/%s",
@@ -325,7 +326,7 @@
 	 *Last = Tmp->NextPkg;
 	 Tmp->NextPkg = 0;
 
-	 FLCache.DropNode(Tmp - FLCache.NodeP);
+	 FLCache.DropNode(Tmp);
       }
       else
       {
@@ -370,8 +371,8 @@
 				  bool DiverCheck)
 {
    pkgFLCache::NodeIterator TmpNde = Nde;
-   unsigned long DiverOwner = 0;
-   unsigned long FileGroup = Nde->File;
+   pkgFLCache::Package* DiverOwner = 0;
+   char* FileGroup = Nde->File;
    const char *FirstOwner = 0;
    for (; Nde.end() == false && FileGroup == Nde->File; Nde++)
    {
@@ -390,7 +391,7 @@
       
       /* This tests trips when we are checking a diversion to see
          if something has already been diverted by this diversion */
-      if (FPkg.Offset() == DiverOwner)
+      if (FPkg == DiverOwner)
 	 continue;
       FirstOwner = FPkg.Name();
       

=== modified file 'apt-inst/filelist.cc'
--- apt-inst/filelist.cc	2008-11-20 21:08:09 +0000
+++ apt-inst/filelist.cc	2008-11-23 12:06:12 +0000
@@ -33,7 +33,6 @@
 									/*}}}*/
 // Include Files							/*{{{*/
 #include <apt-inst/filelist.h>
-#include <apt-pkg/contrib/mmap.h>
 #include <apt-pkg/contrib/error.h>
 #include <apt-pkg/contrib/strutl.h>
 
@@ -79,7 +78,6 @@
    Packages = 0;
    Diversions = 0;
    UniqNodes = 0;
-   memset(Pools,0,sizeof(Pools));
 }
 									/*}}}*/
 // FLCache::Header::CheckSizes - Check if the two headers have same *sz	/*{{{*/
@@ -102,7 +100,7 @@
 // ---------------------------------------------------------------------
 /* If this is a new cache then a new header and hash table are instantaited
    otherwise the existing ones are mearly attached */
-pkgFLCache::pkgFLCache(DynamicMMap &Map) : Map(Map)
+pkgFLCache::pkgFLCache()
 {
    if (_error->PendingError() == true)
       return;
@@ -111,30 +109,18 @@
    LastLookupSize = 0;
    
    // Apply the typecasts
-   HeaderP = (Header *)Map.Data();
-   NodeP = (Node *)Map.Data();
-   DirP = (Directory *)Map.Data();
-   DiverP = (Diversion *)Map.Data();
-   PkgP = (Package *)Map.Data();
-   ConfP = (ConfFile *)Map.Data();
-   StrP = (char *)Map.Data();
-   AnyP = (unsigned char *)Map.Data();
-   
-   // New mapping, create the basic cache structures
-   if (Map.Size() == 0)
-   {
-      Map.RawAllocate(sizeof(pkgFLCache::Header));
-      *HeaderP = pkgFLCache::Header();
-      HeaderP->FileHash = Map.RawAllocate(sizeof(pkgFLCache::Node)*HeaderP->HashSize,
-					  sizeof(pkgFLCache::Node))/sizeof(pkgFLCache::Node);
-   }
-
-   FileHash = NodeP + HeaderP->FileHash;
-   
-   // Setup the dynamic map manager
-   HeaderP->Dirty = true;
-   Map.Sync(0,sizeof(pkgFLCache::Header));
-   Map.UsePools(*HeaderP->Pools,sizeof(HeaderP->Pools)/sizeof(HeaderP->Pools[0]));
+   HeaderP = NULL;
+   NodeP = NULL;
+   DirP = NULL;
+   DiverP = NULL;
+   PkgP = NULL;
+   ConfP = NULL;
+   StrP = NULL;
+   AnyP = NULL;
+   
+   // create the basic cache structures
+  HeaderP = new pkgFLCache::Header();
+  HeaderP->FileHash = new pkgFLCache::Node[HeaderP->HashSize];
 }
 									/*}}}*/
 // FLCache::TreeLookup - Perform a lookup in a generic tree		/*{{{*/
@@ -142,7 +128,7 @@
 /* This is a simple generic tree lookup. The first three entries of
    the Directory structure are used as a template, but any other similar
    structure could be used in it's place. */
-map_ptrloc pkgFLCache::TreeLookup(map_ptrloc *Base,const char *Text,
+pkgFLCache::Directory* pkgFLCache::TreeLookup(Directory** Base,const char *Text,
 				  const char *TextEnd,unsigned long Size,
 				  unsigned int *Count,bool Insert)
 {       
@@ -151,8 +137,8 @@
    // Check our last entry cache
    if (LastTreeLookup != 0 && LastLookupSize == Size)
    {
-      Dir = (pkgFLCache::Directory *)(AnyP + LastTreeLookup*Size);
-      if (stringcmp(Text,TextEnd,StrP + Dir->Name) == 0)
+      Dir = LastTreeLookup;
+      if (stringcmp(Text,TextEnd,Dir->Name) == 0)
 	 return LastTreeLookup; 
    }   
    
@@ -164,21 +150,19 @@
 	 if (Insert == false)
 	    return 0;
 	 
-	 *Base = Map.Allocate(Size);
-	 if (*Base == 0)
-	    return 0;
+	 *Base = new pkgFLCache::Directory;
 	 
 	 (*Count)++;
-	 Dir = (pkgFLCache::Directory *)(AnyP + *Base*Size);
-	 Dir->Name = Map.WriteString(Text,TextEnd - Text);
+	 Dir = *Base;
+	 Dir->Name = strndup(Text,TextEnd - Text);
 	 LastTreeLookup = *Base;
 	 LastLookupSize = Size;
 	 return *Base;
       }
       
       // Compare this node
-      Dir = (pkgFLCache::Directory *)(AnyP + *Base*Size);
-      int Res = stringcmp(Text,TextEnd,StrP + Dir->Name);
+      Dir = *Base;
+      int Res = stringcmp(Text,TextEnd,Dir->Name);
       if (Res == 0)
       {
 	 LastTreeLookup = *Base;
@@ -196,14 +180,14 @@
 // FLCache::PrintTree - Print out a tree				/*{{{*/
 // ---------------------------------------------------------------------
 /* This is a simple generic tree dumper, ment for debugging. */
-void pkgFLCache::PrintTree(map_ptrloc Base,unsigned long Size)
+void pkgFLCache::PrintTree(Directory* Base,unsigned long Size)
 {
    if (Base == 0)
       return;
    
-   pkgFLCache::Directory *Dir = (pkgFLCache::Directory *)(AnyP + Base*Size);
+   pkgFLCache::Directory *Dir = Base;
    PrintTree(Dir->Left,Size);
-   cout << (StrP + Dir->Name) << endl;
+   cout << Dir->Name << endl;
    PrintTree(Dir->Right,Size);
 }
 									/*}}}*/
@@ -217,12 +201,12 @@
    if (NameEnd == 0)
       NameEnd = Name + strlen(Name);
    
-   map_ptrloc Pos = TreeLookup(&HeaderP->Packages,Name,NameEnd,
+   Package* Pos = (Package*)TreeLookup((Directory**)&HeaderP->Packages,Name,NameEnd,
 			       sizeof(pkgFLCache::Package),
 			       &HeaderP->PackageCount,Insert);
    if (Pos == 0)
       return pkgFLCache::PkgIterator();
-   return pkgFLCache::PkgIterator(*this,PkgP + Pos);
+   return pkgFLCache::PkgIterator(*this,Pos);
 }
 									/*}}}*/
 // FLCache::GetNode - Get the node associated with the filename		/*{{{*/
@@ -234,7 +218,7 @@
    the name group. */
 pkgFLCache::NodeIterator pkgFLCache::GetNode(const char *Name,
 					     const char *NameEnd,
-					     map_ptrloc Loc,
+					     Package* Loc,
 					     bool Insert,bool Divert)
 {
    // Split the name into file and directory, hashing as it is copied 
@@ -248,15 +232,15 @@
    }
    
    // Search for it
-   Node *Hash = NodeP + HeaderP->FileHash + (HashPos % HeaderP->HashSize);
+   Node *Hash = HeaderP->FileHash + (HashPos % HeaderP->HashSize);
    int Res = 0;
-   map_ptrloc FilePtr = 0;
+   char* FilePtr = 0;
    while (Hash->Pointer != 0)
    {
       // Compare
-      Res = stringcmp(File+1,NameEnd,StrP + Hash->File);
+      Res = stringcmp(File+1,NameEnd,Hash->File);
       if (Res == 0)
-	 Res = stringcmp(Name,File,StrP + DirP[Hash->Dir].Name);
+	 Res = stringcmp(Name,File,Hash->Dir->Name);
       
       // Diversion?
       if (Res == 0 && Insert == true)
@@ -284,7 +268,7 @@
 	 break;
       
       if (Hash->Next != 0)
-	 Hash = NodeP + Hash->Next;
+	 Hash = Hash->Next;
       else
 	 break;
    }   
@@ -294,7 +278,7 @@
       return NodeIterator(*this);
 
    // Find a directory node
-   map_ptrloc Dir = TreeLookup(&HeaderP->DirTree,Name,File,
+   Directory* Dir = TreeLookup(&HeaderP->DirTree,Name,File,
 			       sizeof(pkgFLCache::Directory),
 			       &HeaderP->DirCount,true);
    if (Dir == 0)
@@ -306,20 +290,16 @@
       // Overwrite or append
       if (Res > 0)
       {
-	 Node *Next = NodeP + Map.Allocate(sizeof(*Hash));
-	 if (Next == NodeP)
-	    return NodeIterator(*this);
+	 Node *Next = new Node;
 	 *Next = *Hash;
-	 Hash->Next = Next - NodeP;
+	 Hash->Next = Next;
       }
       else
       {
-	 unsigned long NewNext = Map.Allocate(sizeof(*Hash));
-	 if (NewNext == 0)
-	    return NodeIterator(*this);
-	 NodeP[NewNext].Next = Hash->Next;
+	 Node* NewNext = new Node;
+	 NewNext->Next = Hash->Next;
 	 Hash->Next = NewNext;
-	 Hash = NodeP + Hash->Next;
+	 Hash = Hash->Next;
       }      
    }      
    
@@ -335,14 +315,14 @@
    else
    {
       HeaderP->UniqNodes++;
-      Hash->File = Map.WriteString(File+1,NameEnd - File-1);
+      Hash->File = strndup(File+1,NameEnd - File-1);
    }
    
    // Link the node to the package list
    if (Divert == false && Loc == 0)
    {
-      Hash->Next = PkgP[Loc].Files;
-      PkgP[Loc].Files = Hash - NodeP;
+      Hash->Next = Loc->Files;
+      Loc->Files = Hash;
    }
    
    HeaderP->NodeCount++;
@@ -362,19 +342,19 @@
    HashPos = 1637*HashPos + '/';
    for (const char *I = Nde.File(); *I != 0; I++)
       HashPos = 1637*HashPos + *I;
-   return NodeP + HeaderP->FileHash + (HashPos % HeaderP->HashSize);
+   return HeaderP->FileHash + (HashPos % HeaderP->HashSize);
 }
 									/*}}}*/
 // FLCache::DropNode - Drop a node from the hash table			/*{{{*/
 // ---------------------------------------------------------------------
 /* This erases a node from the hash table. Note that this does not unlink
    the node from the package linked list. */
-void pkgFLCache::DropNode(map_ptrloc N)
+void pkgFLCache::DropNode(Node* N)
 {
    if (N == 0)
       return;
    
-   NodeIterator Nde(*this,NodeP + N);
+   NodeIterator Nde(*this,N);
    
    if (Nde->NextPkg != 0)
       _error->Warning(_("DropNode called on still linked node"));
@@ -393,7 +373,7 @@
 	    Hash->Pointer = 0;
 	    if (Hash->Next == 0)
 	       return;
-	    *Hash = NodeP[Hash->Next];
+	    Hash = Hash->Next;
 	    // Release Hash->Next
 	    return;
 	 }
@@ -404,7 +384,7 @@
       
       Last = Hash;
       if (Hash->Next != 0)
-	 Hash = NodeP + Hash->Next;
+	 Hash = Hash->Next;
       else
 	 break;
    }   
@@ -427,10 +407,10 @@
    that where not loaded (ie missing from the diversion file) */
 void pkgFLCache::FinishDiverLoad()
 {
-   map_ptrloc *Cur = &HeaderP->Diversions;
+   Diversion** Cur = &HeaderP->Diversions;
    while (*Cur != 0) 
    {
-      Diversion *Div = DiverP + *Cur;
+      Diversion *Div = *Cur;
       if ((Div->Flags & Diversion::Touched) == Diversion::Touched)
       {
 	 Cur = &Div->Next;
@@ -448,7 +428,7 @@
 // ---------------------------------------------------------------------
 /* Add a new diversion to the diverion tables and make sure that it is
    unique and non-chaining. */
-bool pkgFLCache::AddDiversion(PkgIterator const &Owner,
+bool pkgFLCache::AddDiversion(PkgIterator &Owner,
 			      const char *From,const char *To)
 {   
    /* Locate the two hash nodes we are going to manipulate. If there
@@ -464,26 +444,26 @@
       return _error->Error(_("Internal error in AddDiversion"));
 
    // Now, try to reclaim an existing diversion..
-   map_ptrloc Diver = 0;
+   Diversion* Diver = 0;
    if (FromN->Pointer != 0)
-      Diver = FromN->Pointer;
+      Diver = (Diversion*)FromN->Pointer;
   
    /* Make sure from and to point to the same diversion, if they dont
       then we are trying to intermix diversions - very bad */
    if (ToN->Pointer != 0 && ToN->Pointer != Diver)
    {
+      Diversion *Div = (Diversion*)(ToN->Pointer);
       // It could be that the other diversion is no longer in use
-      if ((DiverP[ToN->Pointer].Flags & Diversion::Touched) == Diversion::Touched)	 
+      if ((Div->Flags & Diversion::Touched) == Diversion::Touched)	 
 	 return _error->Error(_("Trying to overwrite a diversion, %s -> %s and %s/%s"),
 			      From,To,ToN.File(),ToN.Dir().Name());
       
       // We can erase it.
-      Diversion *Div = DiverP + ToN->Pointer;
       ToN->Pointer = 0;
       
-      if (Div->DivertTo == ToN.Offset())
+      if (Div->DivertTo == ToN)
 	 Div->DivertTo = 0;
-      if (Div->DivertFrom == ToN.Offset())
+      if (Div->DivertFrom == ToN)
 	 Div->DivertFrom = 0;
       
       // This diversion will be cleaned up by FinishDiverLoad
@@ -492,33 +472,31 @@
    // Allocate a new diversion
    if (Diver == 0)
    {
-      Diver = Map.Allocate(sizeof(Diversion));
-      if (Diver == 0)
-	 return false;
-      DiverP[Diver].Next = HeaderP->Diversions;
+      Diver = new Diversion;
+      Diver->Next = HeaderP->Diversions;
       HeaderP->Diversions = Diver;
       HeaderP->DiversionCount++;
    }
 
    // Can only have one diversion of the same files
-   Diversion *Div = DiverP + Diver;
+   Diversion *Div = Diver;
    if ((Div->Flags & Diversion::Touched) == Diversion::Touched)
       return _error->Error(_("Double add of diversion %s -> %s"),From,To);
    
    // Setup the From/To links
-   if (Div->DivertFrom != FromN.Offset() && Div->DivertFrom != ToN.Offset())
+   if (Div->DivertFrom != FromN && Div->DivertFrom != ToN)
       DropNode(Div->DivertFrom);
-   Div->DivertFrom = FromN.Offset();
-   if (Div->DivertTo != FromN.Offset() && Div->DivertTo != ToN.Offset())
+   Div->DivertFrom = FromN;
+   if (Div->DivertTo != FromN && Div->DivertTo != ToN)
       DropNode(Div->DivertTo);
-   Div->DivertTo = ToN.Offset();
+   Div->DivertTo = ToN;
    
    // Link it to the two nodes
    FromN->Pointer = Diver;
    ToN->Pointer = Diver;
    
    // And the package
-   Div->OwnerPkg = Owner.Offset();
+   Div->OwnerPkg = Owner;
    Div->Flags |= Diversion::Touched;
    
    return true;
@@ -532,14 +510,14 @@
    the proper package. Duplicate conf files (across packages) are left
    up to other routines to deal with. */
 bool pkgFLCache::AddConfFile(const char *Name,const char *NameEnd,
-			     PkgIterator const &Owner,
+			     PkgIterator &Owner,
 			     const unsigned char *Sum)
 {
    NodeIterator Nde = GetNode(Name,NameEnd,0,false,false);
    if (Nde.end() == true)
       return true;
    
-   unsigned long File = Nde->File;
+   char* File = Nde->File;
    for (; Nde->File == File && Nde.end() == false; Nde++)
    {
       if (Nde.RealPackage() != Owner)
@@ -549,11 +527,9 @@
 	 return _error->Error(_("Duplicate conf file %s/%s"),Nde.DirN(),Nde.File());
 			      
       // Allocate a new conf file structure
-      map_ptrloc Conf = Map.Allocate(sizeof(ConfFile));
-      if (Conf == 0)
-	 return false;
-      ConfP[Conf].OwnerPkg = Owner.Offset();
-      memcpy(ConfP[Conf].MD5,Sum,sizeof(ConfP[Conf].MD5));
+      ConfFile* Conf = new ConfFile;
+      Conf->OwnerPkg = Owner;
+      memcpy(Conf->MD5,Sum,sizeof(Conf->MD5));
       
       Nde->Pointer = Conf;
       Nde->Flags |= Node::ConfFile;
@@ -572,16 +548,17 @@
    this is used to get a pointer to the owning package */
 pkgFLCache::Package *pkgFLCache::NodeIterator::RealPackage() const
 {
+   Package* Pkg = (Package*)(Nde->Pointer);
    if (Nde->Pointer == 0)
       return 0;
    
    if ((Nde->Flags & Node::ConfFile) == Node::ConfFile)
-      return Owner->PkgP + Owner->ConfP[Nde->Pointer].OwnerPkg;
+      return ((ConfFile*)Pkg)->OwnerPkg;
 
    // Diversions are ignored
    if ((Nde->Flags & Node::Diversion) == Node::Diversion)
       return 0;
    
-   return Owner->PkgP + Nde->Pointer;
+   return Pkg;
 }
 									/*}}}*/

=== modified file 'apt-inst/filelist.h'
--- apt-inst/filelist.h	2008-11-20 21:08:09 +0000
+++ apt-inst/filelist.h	2008-11-23 11:31:32 +0000
@@ -28,9 +28,9 @@
 #ifndef PKGLIB_FILELIST_H
 #define PKGLIB_FILELIST_H
 
-
 #include <cstring>
-#include <apt-pkg/contrib/mmap.h>
+
+typedef void* map_ptrloc;
 
 class pkgFLCache
 {
@@ -48,16 +48,14 @@
    class DiverIterator;
    
    protected:
-   string CacheFile;
-   DynamicMMap &Map;
-   map_ptrloc LastTreeLookup;
+   Directory* LastTreeLookup;
    unsigned long LastLookupSize;
    
    // Helpers for the addition algorithms
-   map_ptrloc TreeLookup(map_ptrloc *Base,const char *Text,const char *TextEnd,
+   Directory* TreeLookup(Directory** Base,const char *Text,const char *TextEnd,
 			 unsigned long Size,unsigned int *Count = 0,
 			 bool Insert = false);
-   
+
    public:
    
    // Pointers to the arrays of items
@@ -75,29 +73,29 @@
    
    // Accessors
    Header &Head() {return *HeaderP;};
-   void PrintTree(map_ptrloc Base,unsigned long Size);
+   void PrintTree(Directory* Base,unsigned long Size);
 
    // Add/Find things
    PkgIterator GetPkg(const char *Name,const char *End,bool Insert);
    inline PkgIterator GetPkg(const char *Name,bool Insert);
    NodeIterator GetNode(const char *Name,
 			const char *NameEnd,
-			map_ptrloc Loc,
+			Package* Loc,
 			bool Insert,bool Divert);
    Node *HashNode(NodeIterator const &N);
-   void DropNode(map_ptrloc Node);
+   void DropNode(Node* Node);
 
    inline DiverIterator DiverBegin();
    
    // Diversion control
    void BeginDiverLoad();
    void FinishDiverLoad();
-   bool AddDiversion(PkgIterator const &Owner,const char *From,
+   bool AddDiversion(PkgIterator &Owner,const char *From,
 		     const char *To);
    bool AddConfFile(const char *Name,const char *NameEnd,
-		    PkgIterator const &Owner,const unsigned char *Sum);
+		    PkgIterator &Owner,const unsigned char *Sum);
 			     
-   pkgFLCache(DynamicMMap &Map);
+   pkgFLCache();
 //   ~pkgFLCache();
 };
 
@@ -127,57 +125,53 @@
    unsigned long UniqNodes;
       
    // Offsets
-   map_ptrloc FileHash;
-   map_ptrloc DirTree;
-   map_ptrloc Packages;
-   map_ptrloc Diversions;
+   Node* FileHash;
+   pkgFLCache::Directory* DirTree;
+   pkgFLCache::Package* Packages;
+   pkgFLCache::Diversion* Diversions;
       
-   /* Allocation pools, there should be one of these for each structure
-      excluding the header */
-   DynamicMMap::Pool Pools[5];
-
    bool CheckSizes(Header &Against) const;
    Header();
 };
 
+struct pkgFLCache::Directory
+{
+   Directory* Left;           // Directory
+   Directory* Right;          // Directory
+   char* Name;           // String
+};
+
 /* The bit field is used to advoid incurring an extra 4 bytes x 40000,
    Pointer is the most infrequently used member of the structure */
 struct pkgFLCache::Node
 {
-   map_ptrloc Dir;            // Dir
-   map_ptrloc File;           // String
-   unsigned Pointer:24;       // Package/Diversion/ConfFile
+   Directory* Dir;            // Dir
+   char* File;           // String
+   void* Pointer;       // Package/Diversion/ConfFile
    unsigned Flags:8;          // Package
-   map_ptrloc Next;           // Node
-   map_ptrloc NextPkg;        // Node
+   Node* Next;           // Node
+   Node* NextPkg;        // Node
 
    enum Flags {Diversion = (1<<0),ConfFile = (1<<1),
                NewConfFile = (1<<2),NewFile = (1<<3),
                Unpacked = (1<<4),Replaced = (1<<5)};
 };
 
-struct pkgFLCache::Directory
-{
-   map_ptrloc Left;           // Directory
-   map_ptrloc Right;          // Directory
-   map_ptrloc Name;           // String
-};
-
 struct pkgFLCache::Package
 {
-   map_ptrloc Left;           // Package
-   map_ptrloc Right;          // Package
-   map_ptrloc Name;           // String
-   map_ptrloc Files;          // Node
+   Package* Left;           // Package
+   Package* Right;          // Package
+   char* Name;           // String
+   pkgFLCache::Node* Files;          // Node
 };
 
 struct pkgFLCache::Diversion
 {
-   map_ptrloc OwnerPkg;       // Package
-   map_ptrloc DivertFrom;     // Node
-   map_ptrloc DivertTo;       // String
+	pkgFLCache::Package* OwnerPkg;       // Package
+	pkgFLCache::Node* DivertFrom;     // Node
+	pkgFLCache::Node* DivertTo;       // String
    
-   map_ptrloc Next;           // Diversion
+   Diversion* Next;           // Diversion
    unsigned long Flags;
 
    enum Flags {Touched = (1<<0)};
@@ -185,7 +179,7 @@
 
 struct pkgFLCache::ConfFile
 {
-   map_ptrloc OwnerPkg;       // Package
+	pkgFLCache::Package* OwnerPkg;       // Package
    unsigned char MD5[16];
 };
 
@@ -205,8 +199,7 @@
    inline operator Package *() {return Pkg == Owner->PkgP?0:Pkg;};
    inline operator Package const *() const {return Pkg == Owner->PkgP?0:Pkg;};
 
-   inline unsigned long Offset() const {return Pkg - Owner->PkgP;};
-   inline const char *Name() const {return Pkg->Name == 0?0:Owner->StrP + Pkg->Name;};
+   inline const char *Name() const {return Pkg->Name;};
    inline pkgFLCache::NodeIterator Files() const;
 
    PkgIterator() : Pkg(0), Owner(0) {};
@@ -227,7 +220,7 @@
    inline operator Directory *() {return Dir == Owner->DirP?0:Dir;};
    inline operator Directory const *() const {return Dir == Owner->DirP?0:Dir;};
 
-   inline const char *Name() const {return Dir->Name == 0?0:Owner->StrP + Dir->Name;};
+   inline const char *Name() const {return Dir->Name;};
 
    DirIterator() : Dir(0), Owner(0) {};
    DirIterator(pkgFLCache &Owner,Directory *Trg) : Dir(Trg), Owner(&Owner) {};
@@ -241,7 +234,7 @@
    public:
 
    // Iteration
-   void operator ++(int) {if (Diver != Owner->DiverP) Diver = Owner->DiverP + Diver->Next;};
+   void operator ++(int) {if (Diver != Owner->DiverP) Diver = Diver->Next;};
    inline void operator ++() {operator ++(0);};
    inline bool end() const {return Owner == 0 || Diver == Owner->DiverP;};
 
@@ -252,7 +245,7 @@
    inline operator Diversion *() {return Diver == Owner->DiverP?0:Diver;};
    inline operator Diversion const *() const {return Diver == Owner->DiverP?0:Diver;};
 
-   inline PkgIterator OwnerPkg() const {return PkgIterator(*Owner,Owner->PkgP + Diver->OwnerPkg);};
+   inline PkgIterator OwnerPkg() const {return PkgIterator(*Owner, Diver->OwnerPkg);};
    inline NodeIterator DivertFrom() const;
    inline NodeIterator DivertTo() const;
 
@@ -269,8 +262,7 @@
    public:
    
    // Iteration
-   void operator ++(int) {if (Nde != Owner->NodeP) Nde = Owner->NodeP + 
-	 (Type == NdePkg?Nde->NextPkg:Nde->Next);};
+   void operator ++(int) {if (Nde != Owner->NodeP) Nde = (Type == NdePkg?Nde->NextPkg:Nde->Next);};
    inline void operator ++() {operator ++(0);};
    inline bool end() const {return Owner == 0 || Nde == Owner->NodeP;};
 
@@ -280,11 +272,10 @@
    inline Node const &operator *() const {return *Nde;};
    inline operator Node *() {return Nde == Owner->NodeP?0:Nde;};
    inline operator Node const *() const {return Nde == Owner->NodeP?0:Nde;};
-   inline unsigned long Offset() const {return Nde - Owner->NodeP;};
-   inline DirIterator Dir() const {return DirIterator(*Owner,Owner->DirP + Nde->Dir);};
-   inline DiverIterator Diversion() const {return DiverIterator(*Owner,Owner->DiverP + Nde->Pointer);};
-   inline const char *File() const {return Nde->File == 0?0:Owner->StrP + Nde->File;};
-   inline const char *DirN() const {return Owner->StrP + Owner->DirP[Nde->Dir].Name;};
+   inline DirIterator Dir() const {return DirIterator(*Owner, Nde->Dir);};
+   inline DiverIterator Diversion() const {return DiverIterator(*Owner, static_cast<pkgFLCache::Diversion*>(Nde->Pointer));};
+   inline const char *File() const {return Nde->File;};
+   inline const char *DirN() const {return Nde->Dir->Name;};
    Package *RealPackage() const;
    
    NodeIterator() : Nde(0), Type(NdeHash), Owner(0) {};
@@ -296,15 +287,15 @@
 /* Inlines with forward references that cannot be included directly in their
    respsective classes */
 inline pkgFLCache::NodeIterator pkgFLCache::DiverIterator::DivertFrom() const 
-   {return NodeIterator(*Owner,Owner->NodeP + Diver->DivertFrom);};
+   {return NodeIterator(*Owner, Diver->DivertFrom);};
 inline pkgFLCache::NodeIterator pkgFLCache::DiverIterator::DivertTo() const
-   {return NodeIterator(*Owner,Owner->NodeP + Diver->DivertTo);};
+   {return NodeIterator(*Owner, Diver->DivertTo);};
 
 inline pkgFLCache::NodeIterator pkgFLCache::PkgIterator::Files() const
-   {return NodeIterator(*Owner,Owner->NodeP + Pkg->Files,Pkg);};
+   {return NodeIterator(*Owner, Pkg->Files,Pkg);};
 
 inline pkgFLCache::DiverIterator pkgFLCache::DiverBegin()
-   {return DiverIterator(*this,DiverP + HeaderP->Diversions);};
+   {return DiverIterator(*this, HeaderP->Diversions);};
 
 inline pkgFLCache::PkgIterator pkgFLCache::GetPkg(const char *Name,bool Insert) 
    {return GetPkg(Name,Name+strlen(Name),Insert);};

=== modified file 'apt-inst/makefile'
--- apt-inst/makefile	2008-11-20 21:18:48 +0000
+++ apt-inst/makefile	2008-11-23 12:08:33 +0000
@@ -12,7 +12,7 @@
 # The library name
 LIBRARY=apt-inst
 LIBEXT=$(LIBSTDCPP_VER)
-MAJOR=1.1
+MAJOR=1.2
 MINOR=0
 SLIBS=$(PTHREADLIB) -lapt-pkg
 APT_DOMAIN:=libapt-inst$(MAJOR)

=== modified file 'apt-pkg/cachefile.cc'
--- apt-pkg/cachefile.cc	2008-11-16 13:58:02 +0000
+++ apt-pkg/cachefile.cc	2008-11-29 21:39:37 +0000
@@ -28,7 +28,7 @@
 // CacheFile::CacheFile - Constructor					/*{{{*/
 // ---------------------------------------------------------------------
 /* */
-pkgCacheFile::pkgCacheFile() : Map(0), Cache(0), DCache(0), Policy(0)
+pkgCacheFile::pkgCacheFile() : Cache(0), DCache(0), Policy(0)
 {
 }
 									/*}}}*/
@@ -40,7 +40,6 @@
    delete DCache;
    delete Policy;
    delete Cache;
-   delete Map;
    _system->UnLock(true);
 }   
 									/*}}}*/
@@ -64,8 +63,9 @@
    if (List.ReadMainList() == false)
       return _error->Error(_("The list of sources could not be read."));
 
-   // Read the caches
-   bool Res = pkgMakeStatusCache(List,Progress,&Map,!WithLock);
+   Cache = new pkgCache();
+   // Build the caches
+   bool Res = pkgMakeStatusCache(*Cache, List,Progress);
    Progress.Done();
    if (Res == false)
       return _error->Error(_("The package lists or status file could not be parsed or opened."));
@@ -74,7 +74,6 @@
    if (_error->empty() == false)
       _error->Warning(_("You may want to run apt-get update to correct these problems"));
 
-   Cache = new pkgCache(Map);
    if (_error->PendingError() == true)
       return false;
    return true;
@@ -118,10 +117,8 @@
    delete DCache;
    delete Policy;
    delete Cache;
-   delete Map;
    _system->UnLock(true);
 
-   Map = 0;
    DCache = 0;
    Policy = 0;
    Cache = 0;

=== modified file 'apt-pkg/cachefile.h'
--- apt-pkg/cachefile.h	2008-01-07 15:47:40 +0000
+++ apt-pkg/cachefile.h	2008-11-16 16:07:19 +0000
@@ -27,7 +27,6 @@
 {
    protected:
    
-   MMap *Map;
    pkgCache *Cache;
    pkgDepCache *DCache;
    

=== modified file 'apt-pkg/cacheiterators.h'
--- apt-pkg/cacheiterators.h	2006-12-14 11:39:29 +0000
+++ apt-pkg/cacheiterators.h	2008-11-29 20:39:04 +0000
@@ -36,19 +36,10 @@
 class pkgCache::PkgIterator
 {
    friend class pkgCache;
+   pkgCache* Owner;
    Package *Pkg;
-   pkgCache *Owner;
    long HashIndex;
 
-   protected:
-   
-   // This constructor is the 'begin' constructor, never use it.
-   inline PkgIterator(pkgCache &Owner) : Owner(&Owner), HashIndex(-1)
-   {
-      Pkg = Owner.PkgP;
-      operator ++(0);
-   };
-   
    public:
 
    enum OkState {NeedsNothing,NeedsUnpack,NeedsConfigure};
@@ -56,7 +47,7 @@
    // Iteration
    void operator ++(int);
    inline void operator ++() {operator ++(0);};
-   inline bool end() const {return Owner == 0 || Pkg == Owner->PkgP?true:false;};
+   inline bool end() const {return !Owner || !Pkg;};
 
    // Comparison
    inline bool operator ==(const PkgIterator &B) const {return Pkg == B.Pkg;};
@@ -66,45 +57,45 @@
    inline Package *operator ->() {return Pkg;};
    inline Package const *operator ->() const {return Pkg;};
    inline Package const &operator *() const {return *Pkg;};
-   inline operator Package *() {return Pkg == Owner->PkgP?0:Pkg;};
-   inline operator Package const *() const {return Pkg == Owner->PkgP?0:Pkg;};
+   inline operator Package *() {return Pkg;};
+   inline operator Package const *() const {return Pkg;};
    inline pkgCache *Cache() {return Owner;};
    
-   inline const char *Name() const {return Pkg->Name == 0?0:Owner->StrP + Pkg->Name;};
-   inline const char *Section() const {return Pkg->Section == 0?0:Owner->StrP + Pkg->Section;};
+   inline const char *Name() const {return Pkg->Name;};
+   inline const char *Section() const {return Pkg->Section;};
    inline bool Purge() const {return Pkg->CurrentState == pkgCache::State::Purge ||
 	 (Pkg->CurrentVer == 0 && Pkg->CurrentState == pkgCache::State::NotInstalled);};
    inline VerIterator VersionList() const;
    inline VerIterator CurrentVer() const;
    inline DepIterator RevDependsList() const;
    inline PrvIterator ProvidesList() const;
-   inline unsigned long Index() const {return Pkg - Owner->PkgP;};
    OkState State() const;
    
    // Constructors
-   inline PkgIterator(pkgCache &Owner,Package *Trg) : Pkg(Trg), Owner(&Owner),
-          HashIndex(0) 
-   { 
-      if (Pkg == 0)
-	 Pkg = Owner.PkgP;
-   };
-   inline PkgIterator() : Pkg(0), Owner(0), HashIndex(0) {};
+   inline PkgIterator(pkgCache& Owner, Package *Trg) : Owner(&Owner), Pkg(Trg), HashIndex(0)
+   {};
+   inline PkgIterator() : Owner(NULL), Pkg(0), HashIndex(0) {};
+   // next used only in begin constructor of pkgcache.h
+   inline PkgIterator(pkgCache& Owner) : Owner(&Owner), Pkg(NULL), HashIndex(-1)
+	{
+		operator++(0);
+	}
 };
 
 // Version Iterator
 class pkgCache::VerIterator
 {
    Version *Ver;
-   pkgCache *Owner;
+   pkgCache* Owner;
 
    void _dummy();
    
    public:
 
    // Iteration
-   void operator ++(int) {if (Ver != Owner->VerP) Ver = Owner->VerP + Ver->NextVer;};
+   void operator ++(int) {if (Ver) Ver = Ver->NextVer;};
    inline void operator ++() {operator ++(0);};
-   inline bool end() const {return Owner == NULL || (Ver == Owner->VerP?true:false);};
+   inline bool end() const {return !Owner || !Ver;};
    inline void operator =(const VerIterator &B) {Ver = B.Ver; Owner = B.Owner;};
    
    // Comparison
@@ -117,20 +108,19 @@
    inline Version const *operator ->() const {return Ver;};
    inline Version &operator *() {return *Ver;};
    inline Version const &operator *() const {return *Ver;};
-   inline operator Version *() {return Ver == Owner->VerP?0:Ver;};
-   inline operator Version const *() const {return Ver == Owner->VerP?0:Ver;};
+   inline operator Version *() {return Ver;};
+   inline operator Version const *() const {return Ver;};
    inline pkgCache *Cache() {return Owner;};
       
-   inline const char *VerStr() const {return Ver->VerStr == 0?0:Owner->StrP + Ver->VerStr;};
-   inline const char *Section() const {return Ver->Section == 0?0:Owner->StrP + Ver->Section;};
-   inline const char *Arch() const {return Ver->Arch == 0?0:Owner->StrP + Ver->Arch;};
-   inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + Ver->ParentPkg);};
+   inline const char *VerStr() const {return Ver->VerStr;};
+   inline const char *Section() const {return Ver->Section;};
+   inline const char *Arch() const {return Ver->Arch;};
+   inline PkgIterator ParentPkg() const {return PkgIterator(*Owner, Ver->ParentPkg);};
    inline DescIterator DescriptionList() const;
    DescIterator TranslatedDescription() const;
    inline DepIterator DependsList() const;
    inline PrvIterator ProvidesList() const;
    inline VerFileIterator FileList() const;
-   inline unsigned long Index() const {return Ver - Owner->VerP;};
    bool Downloadable() const;
    inline const char *PriorityType() {return Owner->Priority(Ver->Priority);};
    string RelStr();
@@ -141,10 +131,7 @@
    inline VerIterator() : Ver(0), Owner(0) {};   
    inline VerIterator(pkgCache &Owner,Version *Trg = 0) : Ver(Trg), 
               Owner(&Owner) 
-   { 
-      if (Ver == 0)
-	 Ver = Owner.VerP;
-   };
+   {};
 };
 
 // Description Iterator
@@ -158,9 +145,9 @@
    public:
 
    // Iteration
-   void operator ++(int) {if (Desc != Owner->DescP) Desc = Owner->DescP + Desc->NextDesc;};
+   void operator ++(int) {if (Desc) Desc = Desc->NextDesc;};
    inline void operator ++() {operator ++(0);};
-   inline bool end() const {return Desc == Owner->DescP?true:false;};
+   inline bool end() const {return !Owner || !Desc;};
    inline void operator =(const DescIterator &B) {Desc = B.Desc; Owner = B.Owner;};
    
    // Comparison
@@ -173,22 +160,17 @@
    inline Description const *operator ->() const {return Desc;};
    inline Description &operator *() {return *Desc;};
    inline Description const &operator *() const {return *Desc;};
-   inline operator Description *() {return Desc == Owner->DescP?0:Desc;};
-   inline operator Description const *() const {return Desc == Owner->DescP?0:Desc;};
+   inline operator Description *() {return Desc;};
+   inline operator Description const *() const {return Desc;};
    inline pkgCache *Cache() {return Owner;};
       
-   inline const char *LanguageCode() const {return Owner->StrP + Desc->language_code;};
-   inline const char *md5() const {return Owner->StrP + Desc->md5sum;};
+   inline const char *LanguageCode() const {return Desc->language_code;};
+   inline const char *md5() const {return Desc->md5sum;};
    inline DescFileIterator FileList() const;
-   inline unsigned long Index() const {return Desc - Owner->DescP;};
 
    inline DescIterator() : Desc(0), Owner(0) {};   
-   inline DescIterator(pkgCache &Owner,Description *Trg = 0) : Desc(Trg), 
-              Owner(&Owner) 
-   { 
-      if (Desc == 0)
-	 Desc = Owner.DescP;
-   };
+   inline DescIterator(pkgCache &Owner,Description *Trg = 0) : Desc(Trg), Owner(&Owner) 
+   {};
 };
 
 // Dependency iterator
@@ -203,10 +185,9 @@
    public:
 
    // Iteration
-   void operator ++(int) {if (Dep != Owner->DepP) Dep = Owner->DepP +
-	(Type == DepVer?Dep->NextDepends:Dep->NextRevDepends);};
+   void operator ++(int) {if (Dep) Dep = (Type == DepVer?Dep->NextDepends:Dep->NextRevDepends);};
    inline void operator ++() {operator ++(0);};
-   inline bool end() const {return Owner == 0 || Dep == Owner->DepP?true:false;};
+   inline bool end() const {return !Owner || !Dep;};
    
    // Comparison
    inline bool operator ==(const DepIterator &B) const {return Dep == B.Dep;};
@@ -217,17 +198,16 @@
    inline Dependency const *operator ->() const {return Dep;};
    inline Dependency &operator *() {return *Dep;};
    inline Dependency const &operator *() const {return *Dep;};
-   inline operator Dependency *() {return Dep == Owner->DepP?0:Dep;};
-   inline operator Dependency const *() const {return Dep == Owner->DepP?0:Dep;};
+   inline operator Dependency *() {return Dep;};
+   inline operator Dependency const *() const {return Dep;};
    inline pkgCache *Cache() {return Owner;};
    
-   inline const char *TargetVer() const {return Dep->Version == 0?0:Owner->StrP + Dep->Version;};
-   inline PkgIterator TargetPkg() {return PkgIterator(*Owner,Owner->PkgP + Dep->Package);};
+   inline const char *TargetVer() const {return Dep->Version;};
+   inline PkgIterator TargetPkg() {return PkgIterator(*Owner, Dep->Package);};
    inline PkgIterator SmartTargetPkg() {PkgIterator R(*Owner,0);SmartTargetPkg(R);return R;};
-   inline VerIterator ParentVer() {return VerIterator(*Owner,Owner->VerP + Dep->ParentVer);};
-   inline PkgIterator ParentPkg() {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[Dep->ParentVer].ParentPkg);};
+   inline VerIterator ParentVer() {return VerIterator(*Owner,Dep->ParentVer);};
+   inline PkgIterator ParentPkg() {return PkgIterator(*Owner,Dep->ParentVer->ParentPkg);};
    inline bool Reverse() {return Type == DepRev;};
-   inline unsigned long Index() const {return Dep - Owner->DepP;};
    bool IsCritical();
    void GlobOr(DepIterator &Start,DepIterator &End);
    Version **AllTargets();   
@@ -237,16 +217,10 @@
    
    inline DepIterator(pkgCache &Owner,Dependency *Trg,Version * = 0) :
           Dep(Trg), Type(DepVer), Owner(&Owner) 
-   {
-      if (Dep == 0)
-	 Dep = Owner.DepP;
-   };
+   {};
    inline DepIterator(pkgCache &Owner,Dependency *Trg,Package *) :
           Dep(Trg), Type(DepRev), Owner(&Owner)
-   {
-      if (Dep == 0)
-	 Dep = Owner.DepP;
-   };
+   {};
    inline DepIterator() : Dep(0), Type(DepVer), Owner(0) {};
 };
 
@@ -262,10 +236,9 @@
    public:
 
    // Iteration
-   void operator ++(int) {if (Prv != Owner->ProvideP) Prv = Owner->ProvideP +
-	(Type == PrvVer?Prv->NextPkgProv:Prv->NextProvides);};
+   void operator ++(int) {if (Prv) Prv = (Type == PrvVer?Prv->NextPkgProv:Prv->NextProvides);};
    inline void operator ++() {operator ++(0);};
-   inline bool end() const {return Owner == 0 || Prv == Owner->ProvideP?true:false;};
+   inline bool end() const {return !Owner || !Prv;};
    
    // Comparison
    inline bool operator ==(const PrvIterator &B) const {return Prv == B.Prv;};
@@ -276,31 +249,24 @@
    inline Provides const *operator ->() const {return Prv;};
    inline Provides &operator *() {return *Prv;};
    inline Provides const &operator *() const {return *Prv;};
-   inline operator Provides *() {return Prv == Owner->ProvideP?0:Prv;};
-   inline operator Provides const *() const {return Prv == Owner->ProvideP?0:Prv;};
+   inline operator Provides *() {return Prv;};
+   inline operator Provides const *() const {return Prv;};
    inline pkgCache *Cache() {return Owner;};
 
-   inline const char *Name() const {return Owner->StrP + Owner->PkgP[Prv->ParentPkg].Name;};
-   inline const char *ProvideVersion() const {return Prv->ProvideVersion == 0?0:Owner->StrP + Prv->ProvideVersion;};
-   inline PkgIterator ParentPkg() {return PkgIterator(*Owner,Owner->PkgP + Prv->ParentPkg);};
-   inline VerIterator OwnerVer() {return VerIterator(*Owner,Owner->VerP + Prv->Version);};
-   inline PkgIterator OwnerPkg() {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[Prv->Version].ParentPkg);};
-   inline unsigned long Index() const {return Prv - Owner->ProvideP;};
+   inline const char *Name() const {return Prv->ParentPkg->Name;};
+   inline const char *ProvideVersion() const {return Prv->ProvideVersion;};
+   inline PkgIterator ParentPkg() {return PkgIterator(*Owner, Prv->ParentPkg);};
+   inline VerIterator OwnerVer() {return VerIterator(*Owner, Prv->Version);};
+   inline PkgIterator OwnerPkg() {return PkgIterator(*Owner,Prv->Version->ParentPkg);};
 
    inline PrvIterator() : Prv(0), Type(PrvVer), Owner(0)  {};
 
-   inline PrvIterator(pkgCache &Owner,Provides *Trg,Version *) :
+   inline PrvIterator(pkgCache &Owner,Provides *Trg,Version* prvVer) :
           Prv(Trg), Type(PrvVer), Owner(&Owner) 
-   {
-      if (Prv == 0)
-	 Prv = Owner.ProvideP;
-   };
-   inline PrvIterator(pkgCache &Owner,Provides *Trg,Package *) : 
+   {};
+   inline PrvIterator(pkgCache &Owner,Provides *Trg,Package* prvPkg) : 
           Prv(Trg), Type(PrvPkg), Owner(&Owner)
-   {
-      if (Prv == 0)
-	 Prv = Owner.ProvideP;
-   };
+   {};
 };
 
 // Package file 
@@ -312,9 +278,9 @@
    public:
 
    // Iteration
-   void operator ++(int) {if (File!= Owner->PkgFileP) File = Owner->PkgFileP + File->NextFile;};
+   void operator ++(int) {if (File) File = File->NextFile;};
    inline void operator ++() {operator ++(0);};
-   inline bool end() const {return File == Owner->PkgFileP?true:false;};
+   inline bool end() const {return !Owner || !File;};
 
    // Comparison
    inline bool operator ==(const PkgFileIterator &B) const {return File == B.File;};
@@ -324,28 +290,26 @@
    inline PackageFile *operator ->() {return File;};
    inline PackageFile const *operator ->() const {return File;};
    inline PackageFile const &operator *() const {return *File;};
-   inline operator PackageFile *() {return File == Owner->PkgFileP?0:File;};
-   inline operator PackageFile const *() const {return File == Owner->PkgFileP?0:File;};
+   inline operator PackageFile *() {return File;};
+   inline operator PackageFile const *() const {return File;};
    inline pkgCache *Cache() {return Owner;};
 
-   inline const char *FileName() const {return File->FileName == 0?0:Owner->StrP + File->FileName;};
-   inline const char *Archive() const {return File->Archive == 0?0:Owner->StrP + File->Archive;};
-   inline const char *Component() const {return File->Component == 0?0:Owner->StrP + File->Component;};
-   inline const char *Version() const {return File->Version == 0?0:Owner->StrP + File->Version;};
-   inline const char *Origin() const {return File->Origin == 0?0:Owner->StrP + File->Origin;};
-   inline const char *Label() const {return File->Label == 0?0:Owner->StrP + File->Label;};
-   inline const char *Site() const {return File->Site == 0?0:Owner->StrP + File->Site;};
-   inline const char *Architecture() const {return File->Architecture == 0?0:Owner->StrP + File->Architecture;};
-   inline const char *IndexType() const {return File->IndexType == 0?0:Owner->StrP + File->IndexType;};
-
-   inline unsigned long Index() const {return File - Owner->PkgFileP;};
+   inline const char *FileName() const {return File->FileName;};
+   inline const char *Archive() const {return File->Archive;};
+   inline const char *Component() const {return File->Component;};
+   inline const char *Version() const {return File->Version;};
+   inline const char *Origin() const {return File->Origin;};
+   inline const char *Label() const {return File->Label;};
+   inline const char *Site() const {return File->Site;};
+   inline const char *Architecture() const {return File->Architecture;};
+   inline const char *IndexType() const {return File->IndexType;};
 
    bool IsOk();
    string RelStr();
    
    // Constructors
    inline PkgFileIterator() : Owner(0), File(0) {};
-   inline PkgFileIterator(pkgCache &Owner) : Owner(&Owner), File(Owner.PkgFileP) {};
+   inline PkgFileIterator(pkgCache &Owner) : Owner(&Owner), File(NULL) {};
    inline PkgFileIterator(pkgCache &Owner,PackageFile *Trg) : Owner(&Owner), File(Trg) {};
 };
 
@@ -353,84 +317,82 @@
 class pkgCache::VerFileIterator
 {
    pkgCache *Owner;
-   VerFile *FileP;
+   VerFile *MyFile;
 
    public:
 
    // Iteration
-   void operator ++(int) {if (FileP != Owner->VerFileP) FileP = Owner->VerFileP + FileP->NextFile;};
+   void operator ++(int) {if (MyFile) MyFile = MyFile->NextFile;};
    inline void operator ++() {operator ++(0);};
-   inline bool end() const {return FileP == Owner->VerFileP?true:false;};
+   inline bool end() const {return !Owner || !MyFile;};
 
    // Comparison
-   inline bool operator ==(const VerFileIterator &B) const {return FileP == B.FileP;};
-   inline bool operator !=(const VerFileIterator &B) const {return FileP != B.FileP;};
+   inline bool operator ==(const VerFileIterator &B) const {return MyFile == B.MyFile;};
+   inline bool operator !=(const VerFileIterator &B) const {return MyFile != B.MyFile;};
 			   
    // Accessors
-   inline VerFile *operator ->() {return FileP;};
-   inline VerFile const *operator ->() const {return FileP;};
-   inline VerFile const &operator *() const {return *FileP;};
-   inline operator VerFile *() {return FileP == Owner->VerFileP?0:FileP;};
-   inline operator VerFile const *() const {return FileP == Owner->VerFileP?0:FileP;};
+   inline VerFile *operator ->() {return MyFile;};
+   inline VerFile const *operator ->() const {return MyFile;};
+   inline VerFile const &operator *() const {return *MyFile;};
+   inline operator VerFile *() {return MyFile;};
+   inline operator VerFile const *() const {return MyFile;};
    inline pkgCache *Cache() {return Owner;};
   
-   inline PkgFileIterator File() const {return PkgFileIterator(*Owner,FileP->File + Owner->PkgFileP);};
-   inline unsigned long Index() const {return FileP - Owner->VerFileP;};
+   inline PkgFileIterator File() const {return PkgFileIterator(*Owner,MyFile->File);};
       
-   inline VerFileIterator() : Owner(0), FileP(0) {};
-   inline VerFileIterator(pkgCache &Owner,VerFile *Trg) : Owner(&Owner), FileP(Trg) {};
+   inline VerFileIterator() : Owner(0), MyFile(0) {};
+   inline VerFileIterator(pkgCache &Owner,VerFile *Trg) : Owner(&Owner), MyFile(Trg) {};
 };
 
 // Description File 
 class pkgCache::DescFileIterator
 {
    pkgCache *Owner;
-   DescFile *FileP;
+   DescFile *MyFile;
 
    public:
 
    // Iteration
-   void operator ++(int) {if (FileP != Owner->DescFileP) FileP = Owner->DescFileP + FileP->NextFile;};
+   void operator ++(int) {if (MyFile) MyFile = MyFile->NextFile;};
    inline void operator ++() {operator ++(0);};
-   inline bool end() const {return FileP == Owner->DescFileP?true:false;};
+   inline bool end() const {return !Owner || !MyFile;};
 
    // Comparison
-   inline bool operator ==(const DescFileIterator &B) const {return FileP == B.FileP;};
-   inline bool operator !=(const DescFileIterator &B) const {return FileP != B.FileP;};
+   inline bool operator ==(const DescFileIterator &B) const {return MyFile == B.MyFile;};
+   inline bool operator !=(const DescFileIterator &B) const {return MyFile != B.MyFile;};
 			   
    // Accessors
-   inline DescFile *operator ->() {return FileP;};
-   inline DescFile const *operator ->() const {return FileP;};
-   inline DescFile const &operator *() const {return *FileP;};
-   inline operator DescFile *() {return FileP == Owner->DescFileP?0:FileP;};
-   inline operator DescFile const *() const {return FileP == Owner->DescFileP?0:FileP;};
+   inline DescFile *operator ->() {return MyFile;};
+   inline DescFile const *operator ->() const {return MyFile;};
+   inline DescFile const &operator *() const {return *MyFile;};
+   inline operator DescFile *() {return MyFile;};
+   inline operator DescFile const *() const {return MyFile;};
    inline pkgCache *Cache() {return Owner;};
   
-   inline PkgFileIterator File() const {return PkgFileIterator(*Owner,FileP->File + Owner->PkgFileP);};
-   inline unsigned long Index() const {return FileP - Owner->DescFileP;};
+   inline PkgFileIterator File() const {return PkgFileIterator(*Owner,MyFile->File);};
       
-   inline DescFileIterator() : Owner(0), FileP(0) {};
-   inline DescFileIterator(pkgCache &Owner,DescFile *Trg) : Owner(&Owner), FileP(Trg) {};
+   inline DescFileIterator() : Owner(0), MyFile(0) {};
+   inline DescFileIterator(pkgCache &Owner,DescFile *Trg) : Owner(&Owner), MyFile(Trg) {};
 };
 
 // Inlined Begin functions cant be in the class because of order problems
 inline pkgCache::VerIterator pkgCache::PkgIterator::VersionList() const
-       {return VerIterator(*Owner,Owner->VerP + Pkg->VersionList);};
+       {return VerIterator(*Owner, Pkg->VersionList);};
 inline pkgCache::VerIterator pkgCache::PkgIterator::CurrentVer() const
-       {return VerIterator(*Owner,Owner->VerP + Pkg->CurrentVer);};
+       {return VerIterator(*Owner, Pkg->CurrentVer);};
 inline pkgCache::DepIterator pkgCache::PkgIterator::RevDependsList() const
-       {return DepIterator(*Owner,Owner->DepP + Pkg->RevDepends,Pkg);};
+       {return DepIterator(*Owner, Pkg->RevDepends,Pkg);};
 inline pkgCache::PrvIterator pkgCache::PkgIterator::ProvidesList() const
-       {return PrvIterator(*Owner,Owner->ProvideP + Pkg->ProvidesList,Pkg);};
+       {return PrvIterator(*Owner, Pkg->ProvidesList,Pkg);};
 inline pkgCache::DescIterator pkgCache::VerIterator::DescriptionList() const
-       {return DescIterator(*Owner,Owner->DescP + Ver->DescriptionList);};
+       {return DescIterator(*Owner, Ver->DescriptionList);};
 inline pkgCache::PrvIterator pkgCache::VerIterator::ProvidesList() const
-       {return PrvIterator(*Owner,Owner->ProvideP + Ver->ProvidesList,Ver);};
+       {return PrvIterator(*Owner, Ver->ProvidesList,Ver);};
 inline pkgCache::DepIterator pkgCache::VerIterator::DependsList() const
-       {return DepIterator(*Owner,Owner->DepP + Ver->DependsList,Ver);};
+       {return DepIterator(*Owner, Ver->DependsList,Ver);};
 inline pkgCache::VerFileIterator pkgCache::VerIterator::FileList() const
-       {return VerFileIterator(*Owner,Owner->VerFileP + Ver->FileList);};
+       {return VerFileIterator(*Owner, Ver->FileList);};
 inline pkgCache::DescFileIterator pkgCache::DescIterator::FileList() const
-       {return DescFileIterator(*Owner,Owner->DescFileP + Desc->FileList);};
+       {return DescFileIterator(*Owner, Desc->FileList);};
 
 #endif

=== modified file 'apt-pkg/cdrom.cc'
--- apt-pkg/cdrom.cc	2008-11-16 13:58:02 +0000
+++ apt-pkg/cdrom.cc	2008-11-19 20:24:42 +0000
@@ -1,15 +1,16 @@
 /*
  */
 
-#include<apt-pkg/init.h>
-#include<apt-pkg/contrib/error.h>
-#include<apt-pkg/contrib/cdromutl.h>
-#include<apt-pkg/contrib/strutl.h>
-#include<apt-pkg/cdrom.h>
-#include<sstream>
-#include<fstream>
-#include<config.h>
-#include<apti18n.h>
+#include <apt-pkg/init.h>
+#include <apt-pkg/contrib/error.h>
+#include <apt-pkg/contrib/cdromutl.h>
+#include <apt-pkg/contrib/strutl.h>
+#include <apt-pkg/contrib/fileutl.h>
+#include <apt-pkg/cdrom.h>
+#include <sstream>
+#include <fstream>
+#include <config.h>
+#include <apti18n.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <dirent.h>
@@ -17,7 +18,6 @@
 #include <stdio.h>
 #include <algorithm>
 
-
 #include "indexcopy.h"
 
 using namespace std;

=== modified file 'apt-pkg/clean.cc'
--- apt-pkg/clean.cc	2008-11-16 13:58:02 +0000
+++ apt-pkg/clean.cc	2008-11-16 16:06:38 +0000
@@ -10,6 +10,7 @@
 // Includes								/*{{{*/
 #include <apt-pkg/clean.h>
 #include <apt-pkg/contrib/strutl.h>
+#include <apt-pkg/contrib/fileutl.h>
 #include <apt-pkg/contrib/error.h>
 #include <apt-pkg/contrib/configuration.h>
 

=== removed file 'apt-pkg/contrib/mmap.cc'
--- apt-pkg/contrib/mmap.cc	2008-11-26 20:42:11 +0000
+++ apt-pkg/contrib/mmap.cc	1970-01-01 00:00:00 +0000
@@ -1,288 +0,0 @@
-// -*- mode: cpp; mode: fold -*-
-// Description								/*{{{*/
-// $Id: mmap.cc,v 1.22 2001/05/27 05:19:30 jgg Exp $
-/* ######################################################################
-   
-   MMap Class - Provides 'real' mmap or a faked mmap using read().
-
-   MMap cover class.
-
-   Some broken versions of glibc2 (libc6) have a broken definition
-   of mmap that accepts a char * -- all other systems (and libc5) use
-   void *. We can't safely do anything here that would be portable, so
-   libc6 generates warnings -- which should be errors, g++ isn't properly
-   strict.
-   
-   The configure test notes that some OS's have broken private mmap's
-   so on those OS's we can't use mmap. This means we have to use
-   configure to test mmap and can't rely on the POSIX
-   _POSIX_MAPPED_FILES test.
-   
-   ##################################################################### */
-									/*}}}*/
-// Include Files							/*{{{*/
-#define _BSD_SOURCE
-#include <apt-pkg/contrib/mmap.h>
-#include <apt-pkg/contrib/error.h>
-
-#include <apti18n.h>
-
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-#include <cstring>
-   									/*}}}*/
-
-// MMap::MMap - Constructor						/*{{{*/
-// ---------------------------------------------------------------------
-/* */
-MMap::MMap(FileFd &F,unsigned long Flags) : Flags(Flags), iSize(0),
-                     Base(0)
-{
-   if ((Flags & NoImmMap) != NoImmMap)
-      Map(F);
-}
-									/*}}}*/
-// MMap::MMap - Constructor						/*{{{*/
-// ---------------------------------------------------------------------
-/* */
-MMap::MMap(unsigned long Flags) : Flags(Flags), iSize(0),
-                     Base(0)
-{
-}
-									/*}}}*/
-// MMap::~MMap - Destructor						/*{{{*/
-// ---------------------------------------------------------------------
-/* */
-MMap::~MMap()
-{
-   Close();
-}
-									/*}}}*/
-// MMap::Map - Perform the mapping					/*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool MMap::Map(FileFd &Fd)
-{
-   iSize = Fd.Size();
-   
-   // Set the permissions.
-   int Prot = PROT_READ;
-   int Map = MAP_SHARED;
-   if ((Flags & ReadOnly) != ReadOnly)
-      Prot |= PROT_WRITE;
-   if ((Flags & Public) != Public)
-      Map = MAP_PRIVATE;
-   
-   if (iSize == 0)
-      return _error->Error(_("Can't mmap an empty file"));
-   
-   // Map it.
-   Base = mmap(0,iSize,Prot,Map,Fd.Fd(),0);
-   if (Base == (void *)-1)
-      return _error->Errno("mmap",_("Couldn't make mmap of %lu bytes"),iSize);
-
-   return true;
-}
-									/*}}}*/
-// MMap::Close - Close the map						/*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool MMap::Close(bool DoSync)
-{
-   if ((Flags & UnMapped) == UnMapped || Base == 0 || iSize == 0)
-      return true;
-   
-   if (DoSync == true)
-      Sync();
-   
-   if (munmap((char *)Base,iSize) != 0)
-      _error->Warning("Unable to munmap");
-   
-   iSize = 0;
-   Base = 0;
-   return true;
-}
-									/*}}}*/
-// MMap::Sync - Syncronize the map with the disk			/*{{{*/
-// ---------------------------------------------------------------------
-/* This is done in syncronous mode - the docs indicate that this will 
-   not return till all IO is complete */
-bool MMap::Sync()
-{   
-   if ((Flags & UnMapped) == UnMapped)
-      return true;
-   
-#ifdef _POSIX_SYNCHRONIZED_IO   
-   if ((Flags & ReadOnly) != ReadOnly)
-      if (msync((char *)Base,iSize,MS_SYNC) < 0)
-	 return _error->Errno("msync","Unable to write mmap");
-#endif   
-   return true;
-}
-									/*}}}*/
-// MMap::Sync - Syncronize a section of the file to disk		/*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool MMap::Sync(unsigned long Start,unsigned long Stop)
-{
-   if ((Flags & UnMapped) == UnMapped)
-      return true;
-   
-#ifdef _POSIX_SYNCHRONIZED_IO
-   unsigned long PSize = sysconf(_SC_PAGESIZE);
-   if ((Flags & ReadOnly) != ReadOnly)
-      if (msync((char *)Base+(int)(Start/PSize)*PSize,Stop - Start,MS_SYNC) < 0)
-	 return _error->Errno("msync","Unable to write mmap");
-#endif   
-   return true;
-}
-									/*}}}*/
-
-// DynamicMMap::DynamicMMap - Constructor				/*{{{*/
-// ---------------------------------------------------------------------
-/* */
-DynamicMMap::DynamicMMap(FileFd &F,unsigned long Flags,unsigned long WorkSpace) : 
-             MMap(F,Flags | NoImmMap), Fd(&F), WorkSpace(WorkSpace)
-{
-   if (_error->PendingError() == true)
-      return;
-   
-   unsigned long EndOfFile = Fd->Size();
-   if (EndOfFile > WorkSpace)
-      WorkSpace = EndOfFile;
-   else if(WorkSpace > 0)
-   {
-      Fd->Seek(WorkSpace - 1);
-      char C = 0;
-      Fd->Write(&C,sizeof(C));
-   }
-   
-   Map(F);
-   iSize = EndOfFile;
-}
-									/*}}}*/
-// DynamicMMap::DynamicMMap - Constructor for a non-file backed map	/*{{{*/
-// ---------------------------------------------------------------------
-/* This is just a fancy malloc really.. */
-DynamicMMap::DynamicMMap(unsigned long Flags,unsigned long WorkSpace) :
-             MMap(Flags | NoImmMap | UnMapped), Fd(0), WorkSpace(WorkSpace)
-{
-   if (_error->PendingError() == true)
-      return;
-   
-   Base = new unsigned char[WorkSpace];
-   memset(Base,0,WorkSpace);
-   iSize = 0;
-}
-									/*}}}*/
-// DynamicMMap::~DynamicMMap - Destructor				/*{{{*/
-// ---------------------------------------------------------------------
-/* We truncate the file to the size of the memory data set */
-DynamicMMap::~DynamicMMap()
-{
-   if (Fd == 0)
-   {
-      delete [] (unsigned char *)Base;
-      return;
-   }
-   
-   unsigned long EndOfFile = iSize;
-   iSize = WorkSpace;
-   Close(false);
-   if(ftruncate(Fd->Fd(),EndOfFile) < 0)
-      _error->Errno("ftruncate", _("Failed to truncate file"));
-}  
-									/*}}}*/
-// DynamicMMap::RawAllocate - Allocate a raw chunk of unaligned space	/*{{{*/
-// ---------------------------------------------------------------------
-/* This allocates a block of memory aligned to the given size */
-unsigned long DynamicMMap::RawAllocate(unsigned long Size,unsigned long Aln)
-{
-   unsigned long Result = iSize;
-   if (Aln != 0)
-      Result += Aln - (iSize%Aln);
-   
-   iSize = Result + Size;
-   
-   // Just in case error check
-   if (Result + Size > WorkSpace)
-   {
-	  _error->Error(_("Dynamic MMap ran out of room. Please increase the size "
-				  "of APT::Cache-Limit. Current value: %lu. (man 5 apt.conf)"), WorkSpace);
-      return 0;
-   }
-
-   return Result;
-}
-									/*}}}*/
-// DynamicMMap::Allocate - Pooled aligned allocation			/*{{{*/
-// ---------------------------------------------------------------------
-/* This allocates an Item of size ItemSize so that it is aligned to its
-   size in the file. */
-unsigned long DynamicMMap::Allocate(unsigned long ItemSize)
-{   
-   // Look for a matching pool entry
-   Pool *I;
-   Pool *Empty = 0;
-   for (I = Pools; I != Pools + PoolCount; I++)
-   {
-      if (I->ItemSize == 0)
-	 Empty = I;
-      if (I->ItemSize == ItemSize)
-	 break;
-   }
-
-   // No pool is allocated, use an unallocated one
-   if (I == Pools + PoolCount)
-   {
-      // Woops, we ran out, the calling code should allocate more.
-      if (Empty == 0)
-      {
-	 _error->Error("Ran out of allocation pools");
-	 return 0;
-      }
-      
-      I = Empty;
-      I->ItemSize = ItemSize;
-      I->Count = 0;
-   }
-   
-   // Out of space, allocate some more
-   if (I->Count == 0)
-   {
-      I->Count = 20*1024/ItemSize;
-      I->Start = RawAllocate(I->Count*ItemSize,ItemSize);
-   }   
-
-   I->Count--;
-   unsigned long Result = I->Start;
-   I->Start += ItemSize;  
-   return Result/ItemSize;
-}
-									/*}}}*/
-// DynamicMMap::WriteString - Write a string to the file		/*{{{*/
-// ---------------------------------------------------------------------
-/* Strings are not aligned to anything */
-unsigned long DynamicMMap::WriteString(const char *String,
-				       unsigned long Len)
-{
-   unsigned long Result = iSize;
-   // Just in case error check
-   if (Result + Len > WorkSpace)
-   {
-	  _error->Error(_("Dynamic MMap ran out of room. Please increase the size "
-				  "of APT::Cache-Limit. Current value: %lu. (man 5 apt.conf)"), WorkSpace);
-      return 0;
-   }   
-   
-   if (Len == (unsigned long)-1)
-      Len = strlen(String);
-   iSize += Len + 1;
-   memcpy((char *)Base + Result,String,Len);
-   ((char *)Base)[Result + Len] = 0;
-   return Result;
-}
-									/*}}}*/

=== removed file 'apt-pkg/contrib/mmap.h'
--- apt-pkg/contrib/mmap.h	2008-11-16 13:58:02 +0000
+++ apt-pkg/contrib/mmap.h	1970-01-01 00:00:00 +0000
@@ -1,102 +0,0 @@
-// -*- mode: cpp; mode: fold -*-
-// Description								/*{{{*/
-// $Id: mmap.h,v 1.12 2001/05/14 05:16:43 jgg Exp $
-/* ######################################################################
-   
-   MMap Class - Provides 'real' mmap or a faked mmap using read().
-
-   The purpose of this code is to provide a generic way for clients to
-   access the mmap function. In enviroments that do not support mmap
-   from file fd's this function will use read and normal allocated 
-   memory.
-   
-   Writing to a public mmap will always fully comit all changes when the 
-   class is deleted. Ie it will rewrite the file, unless it is readonly
-
-   The DynamicMMap class is used to help the on-disk data structure 
-   generators. It provides a large allocated workspace and members
-   to allocate space from the workspace in an effecient fashion.
-   
-   This source is placed in the Public Domain, do with it what you will
-   It was originally written by Jason Gunthorpe.
-   
-   ##################################################################### */
-									/*}}}*/
-#ifndef PKGLIB_MMAP_H
-#define PKGLIB_MMAP_H
-
-
-#include <string>
-#include <apt-pkg/contrib/fileutl.h>
-
-using std::string;
-
-/* This should be a 32 bit type, larger tyes use too much ram and smaller
-   types are too small. Where ever possible 'unsigned long' should be used
-   instead of this internal type */
-typedef unsigned int map_ptrloc;
-
-class MMap
-{
-   protected:
-   
-   unsigned long Flags;
-   unsigned long iSize;
-   void *Base;
-
-   bool Map(FileFd &Fd);
-   bool Close(bool DoSync = true);
-   
-   public:
-
-   enum OpenFlags {NoImmMap = (1<<0),Public = (1<<1),ReadOnly = (1<<2),
-                   UnMapped = (1<<3)};
-      
-   // Simple accessors
-   inline operator void *() {return Base;};
-   inline void *Data() {return Base;}; 
-   inline unsigned long Size() {return iSize;};
-   
-   // File manipulators
-   bool Sync();
-   bool Sync(unsigned long Start,unsigned long Stop);
-   
-   MMap(FileFd &F,unsigned long Flags);
-   MMap(unsigned long Flags);
-   virtual ~MMap();
-};
-
-class DynamicMMap : public MMap
-{
-   public:
-   
-   // This is the allocation pool structure
-   struct Pool
-   {
-      unsigned long ItemSize;
-      unsigned long Start;
-      unsigned long Count;
-   };
-   
-   protected:
-   
-   FileFd *Fd;
-   unsigned long WorkSpace;
-   Pool *Pools;
-   unsigned int PoolCount;
-   
-   public:
-
-   // Allocation
-   unsigned long RawAllocate(unsigned long Size,unsigned long Aln = 0);
-   unsigned long Allocate(unsigned long ItemSize);
-   unsigned long WriteString(const char *String,unsigned long Len = (unsigned long)-1);
-   inline unsigned long WriteString(const string &S) {return WriteString(S.c_str(),S.length());};
-   void UsePools(Pool &P,unsigned int Count) {Pools = &P; PoolCount = Count;};
-   
-   DynamicMMap(FileFd &F,unsigned long Flags,unsigned long WorkSpace = 2*1024*1024);
-   DynamicMMap(unsigned long Flags,unsigned long WorkSpace = 2*1024*1024);
-   virtual ~DynamicMMap();
-};
-
-#endif

=== modified file 'apt-pkg/deb/deblistparser.cc'
--- apt-pkg/deb/deblistparser.cc	2008-11-20 20:43:00 +0000
+++ apt-pkg/deb/deblistparser.cc	2008-11-20 21:57:47 +0000
@@ -40,7 +40,7 @@
 // ListParser::UniqFindTagWrite - Find the tag and write a unq string	/*{{{*/
 // ---------------------------------------------------------------------
 /* */
-unsigned long debListParser::UniqFindTagWrite(const char *Tag)
+char* debListParser::UniqFindTagWrite(const char *Tag)
 {
    const char *Start;
    const char *Stop;
@@ -311,7 +311,7 @@
       if (Ver.end() == true)
 	 _error->Warning("Encountered status field in a non-version description");
       else
-	 Pkg->CurrentVer = Ver.Index();
+	 Pkg->CurrentVer = Ver;
    }
    
    return true;

=== modified file 'apt-pkg/deb/deblistparser.h'
--- apt-pkg/deb/deblistparser.h	2006-12-14 11:39:29 +0000
+++ apt-pkg/deb/deblistparser.h	2008-11-20 18:31:44 +0000
@@ -33,7 +33,7 @@
    unsigned long iOffset;
    string Arch;
    
-   unsigned long UniqFindTagWrite(const char *Tag);
+   char* UniqFindTagWrite(const char *Tag);
    bool ParseStatus(pkgCache::PkgIterator Pkg,pkgCache::VerIterator Ver);
    bool ParseDepends(pkgCache::VerIterator Ver,const char *Tag,
 		     unsigned int Type);

=== modified file 'apt-pkg/deb/debversion.cc'
--- apt-pkg/deb/debversion.cc	2008-11-16 13:58:02 +0000
+++ apt-pkg/deb/debversion.cc	2008-11-30 01:03:55 +0000
@@ -124,9 +124,10 @@
 // ---------------------------------------------------------------------
 /* This fragments the version into E:V-R triples and compares each 
    portion separately. */
-int debVersioningSystem::DoCmpVersion(const char *A,const char *AEnd,
-				      const char *B,const char *BEnd)
+int debVersioningSystem::CmpVersion(const char *A, const char *B)
 {
+   const char* AEnd = A + strlen(A);
+   const char* BEnd = B + strlen(B);
    // Strip off the epoch and compare it 
    const char *lhs = A;
    const char *rhs = B;

=== modified file 'apt-pkg/deb/debversion.h'
--- apt-pkg/deb/debversion.h	2006-10-02 14:16:54 +0000
+++ apt-pkg/deb/debversion.h	2008-11-29 23:55:15 +0000
@@ -24,13 +24,11 @@
 			  const char *BEnd);
    
    // Compare versions..
-   virtual int DoCmpVersion(const char *A,const char *Aend,
-			  const char *B,const char *Bend);
+   virtual int CmpVersion(const char *A, const char *B);
    virtual bool CheckDep(const char *PkgVer,int Op,const char *DepVer);
-   virtual int DoCmpReleaseVer(const char *A,const char *Aend,
-			     const char *B,const char *Bend)
+   virtual int CmpReleaseVer(const char *A, const char *B)
    {
-      return DoCmpVersion(A,Aend,B,Bend);
+      return CmpVersion(A,B);
    }   
    virtual string UpstreamVersion(const char *A);
 
@@ -48,15 +46,6 @@
 {
    return debVS.CmpVersion(A,B);
 }
-inline int pkgVersionCompare(const char *A, const char *AEnd, 
-			     const char *B, const char *BEnd)
-{
-   return debVS.DoCmpVersion(A,AEnd,B,BEnd);
-}
-inline int pkgVersionCompare(string A,string B)
-{
-   return debVS.CmpVersion(A,B);
-}
 inline bool pkgCheckDep(const char *DepVer,const char *PkgVer,int Op)
 {
    return debVS.CheckDep(PkgVer,Op,DepVer);

=== modified file 'apt-pkg/depcache.cc'
--- apt-pkg/depcache.cc	2008-11-16 13:58:02 +0000
+++ apt-pkg/depcache.cc	2008-11-28 20:13:35 +0000
@@ -968,9 +968,9 @@
 	 PkgIterator InstPkg(*Cache,0);
 	 
 	 // See if there are direct matches (at the start of the list)
-	 for (; *Cur != 0 && (*Cur)->ParentPkg == P.Index(); Cur++)
+	 for (; *Cur != 0 && (*Cur)->ParentPkg == P; Cur++)
 	 {
-	    PkgIterator Pkg(*Cache,Cache->PkgP + (*Cur)->ParentPkg);
+	    PkgIterator Pkg(*Cache,(*Cur)->ParentPkg);
 	    if (PkgState[Pkg->ID].CandidateVer != *Cur)
 	       continue;
 	    InstPkg = Pkg;
@@ -983,7 +983,7 @@
 	    pkgPrioSortList(*Cache,Cur);
 	    for (; *Cur != 0; Cur++)
 	    {
-	       PkgIterator Pkg(*Cache,Cache->PkgP + (*Cur)->ParentPkg);
+	       PkgIterator Pkg(*Cache, (*Cur)->ParentPkg);
 	       if (PkgState[Pkg->ID].CandidateVer != *Cur)
 		  continue;
 	       InstPkg = Pkg;

=== modified file 'apt-pkg/makefile'
--- apt-pkg/makefile	2008-11-20 21:18:48 +0000
+++ apt-pkg/makefile	2008-11-20 21:57:47 +0000
@@ -19,12 +19,12 @@
 APT_DOMAIN:=libapt-pkg$(MAJOR)
 
 # Source code for the contributed non-core things
-SOURCE_CONTRIB = mmap.cc error.cc strutl.cc \
+SOURCE_CONTRIB = error.cc strutl.cc \
          configuration.cc progress.cc cmndline.cc \
 		 md5.cc sha1.cc sha256.cc hashes.cc \
 		 cdromutl.cc crc-16.cc \
 		 fileutl.cc 
-HEADERS_CONTRIB = mmap.h error.h configuration.h fileutl.h  cmndline.h \
+HEADERS_CONTRIB = error.h configuration.h fileutl.h  cmndline.h \
 	  md5.h crc-16.h cdromutl.h strutl.h sptr.h sha1.h sha256.h hashes.h \
 	  progress.h
 SOURCE+= $(addprefix contrib/,$(SOURCE_CONTRIB))

=== modified file 'apt-pkg/pkgcache.cc'
--- apt-pkg/pkgcache.cc	2008-11-20 20:43:00 +0000
+++ apt-pkg/pkgcache.cc	2008-11-30 00:31:21 +0000
@@ -45,13 +45,12 @@
 /* Simply initialize the header */
 pkgCache::Header::Header()
 {
-   Signature = 0x98FE76DC;
+   Signature = 0x91FA5487;
    
    /* Whenever the structures change the major version should be bumped,
       whenever the generator changes the minor version should be bumped. */
-   MajorVersion = 7;
+   MajorVersion = 8;
    MinorVersion = 0;
-   Dirty = false;
    
    HeaderSz = sizeof(pkgCache::Header);
    PackageSz = sizeof(pkgCache::Package);
@@ -75,11 +74,9 @@
    MaxDescFileSize = 0;
    
    FileList = 0;
-   StringList = 0;
    VerSysName = 0;
    Architecture = 0;
    memset(HashTable,0,sizeof(HashTable));
-   memset(Pools,0,sizeof(Pools));
 }
 									/*}}}*/
 // Cache::Header::CheckSizes - Check if the two headers have same *sz	/*{{{*/
@@ -104,54 +101,9 @@
 // Cache::pkgCache - Constructor					/*{{{*/
 // ---------------------------------------------------------------------
 /* */
-pkgCache::pkgCache(MMap *Map, bool DoMap) : Map(*Map)
-{
-   if (DoMap == true)
-      ReMap();
-}
-									/*}}}*/
-// Cache::ReMap - Reopen the cache file					/*{{{*/
-// ---------------------------------------------------------------------
-/* If the file is already closed then this will open it open it. */
-bool pkgCache::ReMap()
-{
-   // Apply the typecasts.
-   HeaderP = (Header *)Map.Data();
-   PkgP = (Package *)Map.Data();
-   VerFileP = (VerFile *)Map.Data();
-   DescFileP = (DescFile *)Map.Data();
-   PkgFileP = (PackageFile *)Map.Data();
-   VerP = (Version *)Map.Data();
-   DescP = (Description *)Map.Data();
-   ProvideP = (Provides *)Map.Data();
-   DepP = (Dependency *)Map.Data();
-   StringItemP = (StringItem *)Map.Data();
-   StrP = (char *)Map.Data();
-
-   if (Map.Size() == 0 || HeaderP == 0)
-      return _error->Error(_("Empty package cache"));
-   
-   // Check the header
-   Header DefHeader;
-   if (HeaderP->Signature != DefHeader.Signature ||
-       HeaderP->Dirty == true)
-      return _error->Error(_("The package cache file is corrupted"));
-   
-   if (HeaderP->MajorVersion != DefHeader.MajorVersion ||
-       HeaderP->MinorVersion != DefHeader.MinorVersion ||
-       HeaderP->CheckSizes(DefHeader) == false)
-      return _error->Error(_("The package cache file is an incompatible version"));
-
-   // Locate our VS..
-   if (HeaderP->VerSysName == 0 ||
-       (VS = pkgVersioningSystem::GetVS(StrP + HeaderP->VerSysName)) == 0)
-      return _error->Error(_("This APT does not support the versioning system '%s'"),StrP + HeaderP->VerSysName);
-
-   // Chcek the arhcitecture
-   if (HeaderP->Architecture == 0 ||
-       _config->Find("APT::Architecture") != StrP + HeaderP->Architecture)
-      return _error->Error(_("The package cache was built for a different architecture"));
-   return true;
+pkgCache::pkgCache()
+{
+	StringItemStartP = NULL;
 }
 									/*}}}*/
 // Cache::Hash - Hash a string						/*{{{*/
@@ -161,17 +113,14 @@
    table (480 used items) */
 unsigned long pkgCache::sHash(const string &Str) const
 {
-   unsigned long Hash = 0;
-   for (string::const_iterator I = Str.begin(); I != Str.end(); I++)
-      Hash = 5*Hash + tolower(*I);
-   return Hash % _count(HeaderP->HashTable);
+	return sHash(Str.c_str());
 }
 
 unsigned long pkgCache::sHash(const char *Str) const
 {
    unsigned long Hash = 0;
    for (const char *I = Str; *I != 0; I++)
-      Hash = 5*Hash + tolower(*I);
+      Hash = 5*Hash + *I;
    return Hash % _count(HeaderP->HashTable);
 }
 
@@ -182,14 +131,14 @@
 pkgCache::PkgIterator pkgCache::FindPkg(const string &Name)
 {
    // Look at the hash bucket
-   Package *Pkg = PkgP + HeaderP->HashTable[Hash(Name)];
-   for (; Pkg != PkgP; Pkg = PkgP + Pkg->NextPackage)
+   Package *Pkg = HeaderP->HashTable[Hash(Name)];
+   for (; Pkg; Pkg = Pkg->NextPackage)
    {
-      if (Pkg->Name != 0 && StrP[Pkg->Name] == Name[0] &&
-	  stringcasecmp(Name,StrP + Pkg->Name) == 0)
+      if (Pkg->Name != 0 && Pkg->Name[0] == Name[0] &&
+	  stringcmp(Name, Pkg->Name) == 0)
 	 return PkgIterator(*this,Pkg);
    }
-   return PkgIterator(*this,0);
+   return PkgIterator(*this,NULL);
 }
 									/*}}}*/
 // Cache::CompTypeDeb - Return a string describing the compare type	/*{{{*/
@@ -253,14 +202,14 @@
 void pkgCache::PkgIterator::operator ++(int) 
 {
    // Follow the current links
-   if (Pkg != Owner->PkgP)
-      Pkg = Owner->PkgP + Pkg->NextPackage;
+   if (Pkg)
+      Pkg = Pkg->NextPackage;
 
    // Follow the hash table
-   while (Pkg == Owner->PkgP && (HashIndex+1) < (signed)_count(Owner->HeaderP->HashTable))
+   while (!Pkg && (HashIndex+1) < (signed)_count(Owner->HeaderP->HashTable))
    {
       HashIndex++;
-      Pkg = Owner->PkgP + Owner->HeaderP->HashTable[HashIndex];
+      Pkg = Owner->HeaderP->HashTable[HashIndex];
    }
 };
 									/*}}}*/

=== modified file 'apt-pkg/pkgcache.h'
--- apt-pkg/pkgcache.h	2008-11-27 21:56:58 +0000
+++ apt-pkg/pkgcache.h	2008-11-29 23:28:58 +0000
@@ -19,10 +19,11 @@
 #ifndef PKGLIB_PKGCACHE_H
 #define PKGLIB_PKGCACHE_H
 
+typedef void* map_ptrloc;
 
 #include <string>
 #include <time.h>
-#include <apt-pkg/contrib/mmap.h>
+#include <string.h>
 
 using std::string;
     
@@ -93,33 +94,24 @@
    
    protected:
    
-   // Memory mapped cache file
-   string CacheFile;
-   MMap &Map;
-
    unsigned long sHash(const string &S) const;
    unsigned long sHash(const char *S) const;
    
    public:
    
+   Header *HeaderP;
+
    // Pointers to the arrays of items
-   Header *HeaderP;
-   Package *PkgP;
-   VerFile *VerFileP;
-   DescFile *DescFileP;
-   PackageFile *PkgFileP;
-   Version *VerP;
-   Description *DescP;
-   Provides *ProvideP;
-   Dependency *DepP;
-   StringItem *StringItemP;
-   char *StrP;
+   //Package *PkgStartP;
+   //VerFile *VerFileStartP;
+   //DescFile *DescFileStartP;
+   //PackageFile *PkgFileStartP;
+   //Version *VerStartP;
+   //Description *DescStartP;
+   //Provides *ProvideStartP;
+   //Dependency *DepStartP;
+   StringItem *StringItemStartP;
 
-   virtual bool ReMap();
-   inline bool Sync() {return Map.Sync();};
-   inline MMap &GetMap() {return Map;};
-   inline void *DataEnd() {return ((unsigned char *)Map.Data()) + Map.Size();};
-      
    // String hashing function (512 range)
    inline unsigned long Hash(const string &S) const {return sHash(S);};
    inline unsigned long Hash(const char *S) const {return sHash(S);};
@@ -143,7 +135,7 @@
    static const char *CompType(unsigned char Comp);
    static const char *DepType(unsigned char Dep);
    
-   pkgCache(MMap *Map,bool DoMap = true);
+   pkgCache();
    virtual ~pkgCache() {};
 };
 
@@ -154,7 +146,6 @@
    unsigned long Signature;
    short MajorVersion;
    short MinorVersion;
-   bool Dirty;
    
    // Size of structure values
    unsigned short HeaderSz;
@@ -178,19 +169,15 @@
    unsigned long ProvidesCount;
    
    // Offsets
-   map_ptrloc FileList;              // struct PackageFile
-   map_ptrloc StringList;            // struct StringItem
-   map_ptrloc VerSysName;            // StringTable
-   map_ptrloc Architecture;          // StringTable
+   pkgCache::PackageFile* FileList;              // struct PackageFile
+   //map_ptrloc StringList;            // struct StringItem
+   char* VerSysName;            // StringTable
+   char* Architecture;          // StringTable
    unsigned long MaxVerFileSize;
    unsigned long MaxDescFileSize;
 
-   /* Allocation pools, there should be one of these for each structure
-      excluding the header */
-   DynamicMMap::Pool Pools[8];
-   
    // Rapid package name lookup
-   map_ptrloc HashTable[2*1048];
+   pkgCache::Package* HashTable[8*1048];
 
    bool CheckSizes(Header &Against) const;
    Header();
@@ -199,15 +186,15 @@
 struct pkgCache::Package
 {
    // Pointers
-   map_ptrloc Name;              // Stringtable
-   map_ptrloc VersionList;       // Version
-   map_ptrloc CurrentVer;        // Version
-   map_ptrloc Section;           // StringTable (StringItem)
-      
+   char* Name;              // Stringtable
+   pkgCache::Version* VersionList;       // Version
+   pkgCache::Version* CurrentVer;        // Version
+   char* Section;           // StringTable (StringItem)
+
    // Linked list 
-   map_ptrloc NextPackage;       // Package
-   map_ptrloc RevDepends;        // Dependency
-   map_ptrloc ProvidesList;      // Provides
+   Package* NextPackage;       // Package
+   pkgCache::Dependency* RevDepends;        // Dependency
+   pkgCache::Provides* ProvidesList;      // Provides
 
    // Install/Remove/Purge etc
    unsigned char SelectedState;     // What
@@ -216,64 +203,89 @@
    
    unsigned int ID;
    unsigned long Flags;
+
+   Package()
+   {
+	   memset(this, 0, sizeof(*this));
+   }
 };
 
 struct pkgCache::PackageFile
 {
    // Names
-   map_ptrloc FileName;        // Stringtable
-   map_ptrloc Archive;         // Stringtable
-   map_ptrloc Component;       // Stringtable
-   map_ptrloc Version;         // Stringtable
-   map_ptrloc Origin;          // Stringtable
-   map_ptrloc Label;           // Stringtable
-   map_ptrloc Architecture;    // Stringtable
-   map_ptrloc Site;            // Stringtable
-   map_ptrloc IndexType;       // Stringtable
+   char* FileName;        // Stringtable
+   char* Archive;         // Stringtable
+   char* Component;       // Stringtable
+   char* Version;         // Stringtable
+   char* Origin;          // Stringtable
+   char* Label;           // Stringtable
+   char* Architecture;    // Stringtable
+   char* Site;            // Stringtable
+   char* IndexType;       // Stringtable
    unsigned long Size;            
    unsigned long Flags;
    
    // Linked list
-   map_ptrloc NextFile;        // PackageFile
+   PackageFile* NextFile;        // PackageFile
    unsigned int ID;
    time_t mtime;                  // Modification time for the file
+
+   PackageFile()
+   {
+	   memset(this, 0, sizeof(*this));
+   }
 };
 
 struct pkgCache::VerFile
 {
-   map_ptrloc File;           // PackageFile
-   map_ptrloc NextFile;       // PkgVerFile
-   map_ptrloc Offset;         // File offset
+	pkgCache::PackageFile* File;           // PackageFile
+	pkgCache::VerFile* NextFile;       // PkgVerFile
+   unsigned int Offset;         // File offset
    unsigned short Size;
+
+   VerFile()
+   {
+	   memset(this, 0, sizeof(*this));
+   }
 };
 
 struct pkgCache::DescFile
 {
-   map_ptrloc File;           // PackageFile
-   map_ptrloc NextFile;       // PkgVerFile
-   map_ptrloc Offset;         // File offset
+	pkgCache::PackageFile* File;           // PackageFile
+	pkgCache::DescFile* NextFile;       // PkgDescFile
+   unsigned int Offset;         // File offset
    unsigned short Size;
+
+   DescFile()
+   {
+	   memset(this, 0, sizeof(*this));
+   }
 };
 
 struct pkgCache::Version
 {
-   map_ptrloc VerStr;            // Stringtable
-   map_ptrloc Section;           // StringTable (StringItem)
-   map_ptrloc Arch;              // StringTable
+   char* VerStr;            // Stringtable
+   char* Section;           // StringTable (StringItem)
+   char* Arch;              // StringTable
       
    // Lists
-   map_ptrloc FileList;          // VerFile
-   map_ptrloc NextVer;           // Version
-   map_ptrloc DescriptionList;   // Description
-   map_ptrloc DependsList;       // Dependency
-   map_ptrloc ParentPkg;         // Package
-   map_ptrloc ProvidesList;      // Provides
+   pkgCache::VerFile* FileList;          // VerFile
+   Version* NextVer;           // Version
+   pkgCache::Description* DescriptionList;   // Description
+   pkgCache::Dependency* DependsList;       // Dependency
+   pkgCache::Package* ParentPkg;         // Package
+   pkgCache::Provides* ProvidesList;      // Provides
    
-   map_ptrloc Size;              // These are the .deb size
-   map_ptrloc InstalledSize;
+   unsigned long Size;              // These are the .deb size
+   unsigned long InstalledSize;
    unsigned short Hash;
    unsigned int ID;
    unsigned char Priority;
+
+   Version()
+   {
+	   memset(this, 0, sizeof(*this));
+   }
 };
 
 struct pkgCache::Description
@@ -281,44 +293,59 @@
    // Language Code store the description translation language code. If
    // the value has a 0 lenght then this is readed using the Package
    // file else the Translation-CODE are used.
-   map_ptrloc language_code;     // StringTable
-   map_ptrloc md5sum;            // StringTable
+   char* language_code;     // StringTable
+   char* md5sum;            // StringTable
 
    // Linked list 
-   map_ptrloc FileList;          // DescFile
-   map_ptrloc NextDesc;          // Description
-   map_ptrloc ParentPkg;         // Package
+   pkgCache::DescFile* FileList;          // DescFile
+   Description* NextDesc;          // Description
+   pkgCache::Package* ParentPkg;         // Package
 
    unsigned int ID;
+
+   Description()
+   {
+	   memset(this, 0, sizeof(*this));
+   }
 };
 
 struct pkgCache::Dependency
 {
-   map_ptrloc Version;         // Stringtable
-   map_ptrloc Package;         // Package
-   map_ptrloc NextDepends;     // Dependency
-   map_ptrloc NextRevDepends;  // Dependency
-   map_ptrloc ParentVer;       // Version
+   char* Version;         // Stringtable
+   pkgCache::Package* Package;         // Package
+   Dependency* NextDepends;     // Dependency
+   Dependency* NextRevDepends;  // Dependency
+   pkgCache::Version* ParentVer;       // Version
    
    // Specific types of depends
    unsigned int ID;   
    unsigned char Type;
    unsigned char CompareOp;
+
+   Dependency()
+   {
+	   memset(this, 0, sizeof(*this));
+   }
 };
 
 struct pkgCache::Provides
 {
-   map_ptrloc ParentPkg;        // Pacakge
-   map_ptrloc Version;          // Version
-   map_ptrloc ProvideVersion;   // Stringtable
-   map_ptrloc NextProvides;     // Provides
-   map_ptrloc NextPkgProv;      // Provides
+	pkgCache::Package* ParentPkg;        // Pacakge
+	pkgCache::Version* Version;          // Version
+   char* ProvideVersion;   // Stringtable
+   Provides* NextProvides;     // Provides
+   Provides* NextPkgProv;      // Provides
+
+   Provides()
+   {
+	   memset(this, 0, sizeof(*this));
+   }
 };
 
 struct pkgCache::StringItem
 {
-   map_ptrloc String;        // Stringtable
-   map_ptrloc NextItem;      // StringItem
+   char* String;        // Stringtable
+   StringItem* NextItem;      // StringItem
 };
 
 #include <apt-pkg/cacheiterators.h>
@@ -326,11 +353,11 @@
 inline pkgCache::PkgIterator pkgCache::PkgBegin() 
        {return PkgIterator(*this);};
 inline pkgCache::PkgIterator pkgCache::PkgEnd() 
-       {return PkgIterator(*this,PkgP);};
+       {return PkgIterator(*this,NULL);};
 inline pkgCache::PkgFileIterator pkgCache::FileBegin()
-       {return PkgFileIterator(*this,PkgFileP + HeaderP->FileList);};
+       {return PkgFileIterator(*this, HeaderP->FileList);};
 inline pkgCache::PkgFileIterator pkgCache::FileEnd()
-       {return PkgFileIterator(*this,PkgFileP);};
+       {return PkgFileIterator(*this,NULL);};
 
 // Oh I wish for Real Name Space Support
 class pkgCache::Namespace

=== modified file 'apt-pkg/pkgcachegen.cc'
--- apt-pkg/pkgcachegen.cc	2008-11-27 21:56:58 +0000
+++ apt-pkg/pkgcachegen.cc	2008-11-29 23:55:47 +0000
@@ -38,9 +38,8 @@
 
 // CacheGenerator::pkgCacheGenerator - Constructor			/*{{{*/
 // ---------------------------------------------------------------------
-/* We set the diry flag and make sure that is written to the disk */
-pkgCacheGenerator::pkgCacheGenerator(DynamicMMap *pMap,OpProgress *Prog) :
-		    Map(*pMap), Cache(pMap,false), Progress(Prog),
+pkgCacheGenerator::pkgCacheGenerator(pkgCache& Cache, OpProgress *Prog) :
+		    Cache(Cache), Progress(Prog),
 		    FoundFileDeps(0)
 {
    CurrentFile = 0;
@@ -49,33 +48,16 @@
    if (_error->PendingError() == true)
       return;
 
-   if (Map.Size() == 0)
-   {
-      // Setup the map interface..
-      Cache.HeaderP = (pkgCache::Header *)Map.Data();
-      Map.RawAllocate(sizeof(pkgCache::Header));
-      Map.UsePools(*Cache.HeaderP->Pools,sizeof(Cache.HeaderP->Pools)/sizeof(Cache.HeaderP->Pools[0]));
-      
-      // Starting header
-      *Cache.HeaderP = pkgCache::Header();
-      Cache.HeaderP->VerSysName = Map.WriteString(_system->VS->Label);
-      Cache.HeaderP->Architecture = Map.WriteString(_config->Find("APT::Architecture"));
-      Cache.ReMap(); 
-   }
-   else
-   {
-      // Map directly from the existing file
-      Cache.ReMap(); 
-      Map.UsePools(*Cache.HeaderP->Pools,sizeof(Cache.HeaderP->Pools)/sizeof(Cache.HeaderP->Pools[0]));
-      if (Cache.VS != _system->VS)
-      {
-	 _error->Error(_("Cache has an incompatible versioning system"));
-	 return;
-      }      
-   }
-   
-   Cache.HeaderP->Dirty = true;
-   Map.Sync(0,sizeof(pkgCache::Header));
+  // Starting header
+  Cache.HeaderP = new pkgCache::Header();
+  Cache.HeaderP->VerSysName = WriteString(_system->VS->Label);
+  Cache.HeaderP->Architecture = WriteString(_config->Find("APT::Architecture"));
+
+  // Locate our VS..
+  if ((Cache.VS = pkgVersioningSystem::GetVS(Cache.HeaderP->VerSysName)) == 0)
+  {
+	  _error->Error(_("This APT does not support the versioning system '%s'"), Cache.HeaderP->VerSysName);
+  }
 }
 									/*}}}*/
 // CacheGenerator::~pkgCacheGenerator - Destructor 			/*{{{*/
@@ -86,11 +68,6 @@
 {
    if (_error->PendingError() == true)
       return;
-   if (Map.Sync() == false)
-      return;
-   
-   Cache.HeaderP->Dirty = false;
-   Map.Sync(0,sizeof(pkgCache::Header));
 }
 									/*}}}*/
 // CacheGenerator::MergeList - Merge the package list			/*{{{*/
@@ -98,166 +75,166 @@
 /* This provides the generation of the entries in the cache. Each loop
    goes through a single package record from the underlying parse engine. */
 bool pkgCacheGenerator::MergeList(ListParser &List,
-				  pkgCache::VerIterator *OutVer)
+		pkgCache::VerIterator *OutVer)
 {
-   List.Owner = this;
-
-   unsigned int Counter = 0;
-   while (List.Step() == true)
-   {
-      // Get a pointer to the package structure
-      string PackageName = List.Package();
-      if (PackageName.empty() == true)
-	 return false;
-      
-      pkgCache::PkgIterator Pkg;
-      if (NewPackage(Pkg,PackageName) == false)
-	 return _error->Error(_("Error occurred while processing %s (NewPackage)"),PackageName.c_str());
-      Counter++;
-      if (Counter % 100 == 0 && Progress != 0)
-	 Progress->Progress(List.Offset());
-
-      /* Get a pointer to the version structure. We know the list is sorted
-         so we use that fact in the search. Insertion of new versions is
-	 done with correct sorting */
-      string Version = List.Version();
-      if (Version.empty() == true)
-      {
-	 // we first process the package, then the descriptions
-	 // (this has the bonus that we get MMap error when we run out
-	 //  of MMap space)
-	 if (List.UsePackage(Pkg,pkgCache::VerIterator(Cache)) == false)
-	    return _error->Error(_("Error occurred while processing %s (UsePackage1)"),
-				 PackageName.c_str());
-
- 	 // Find the right version to write the description
- 	 MD5SumValue CurMd5 = List.Description_md5();
- 	 pkgCache::VerIterator Ver = Pkg.VersionList();
- 	 map_ptrloc *LastVer = &Pkg->VersionList;
-
-  	 for (; Ver.end() == false; LastVer = &Ver->NextVer, Ver++) 
- 	 {
- 	    pkgCache::DescIterator Desc = Ver.DescriptionList();
- 	    map_ptrloc *LastDesc = &Ver->DescriptionList;
-
-	    // don't add a new description if we have one for the given
-	    // md5 && language
-		for ( ; Desc.end() == false; LastDesc = &Desc->NextDesc, Desc++)
-			if (MD5SumValue(Desc.md5()) == CurMd5 && 
-					Desc.LanguageCode() == List.DescriptionLanguage())
-			{
-				continue;
-			}
-	    
- 	    for (Desc = Ver.DescriptionList();
-		 Desc.end() == false; 
-		 LastDesc = &Desc->NextDesc, Desc++)
-	    {
- 	       if (MD5SumValue(Desc.md5()) == CurMd5) 
-               {
- 		  // Add new description
- 		  *LastDesc = NewDescription(Desc, List.DescriptionLanguage(), CurMd5, *LastDesc);
- 		  Desc->ParentPkg = Pkg.Index();
-		  
- 		  if (NewFileDesc(Desc,List) == false)
- 		     return _error->Error(_("Error occurred while processing %s (NewFileDesc1)"),PackageName.c_str());
- 		  break;
- 	       }
-	    }
- 	 }
-
-	 continue;
-      }
-
-      pkgCache::VerIterator Ver = Pkg.VersionList();
-      map_ptrloc *LastVer = &Pkg->VersionList;
-      int Res = 1;
-      for (; Ver.end() == false; LastVer = &Ver->NextVer, Ver++)
-      {
-	 Res = Cache.VS->CmpVersion(Version,Ver.VerStr());
-	 if (Res >= 0)
-	    break;
-      }
-      
-      /* We already have a version for this item, record that we
-         saw it */
-      unsigned long Hash = List.VersionHash();
-      if (Res == 0 && Ver->Hash == Hash)
-      {
-	 if (List.UsePackage(Pkg,Ver) == false)
-	    return _error->Error(_("Error occurred while processing %s (UsePackage2)"),
-				 PackageName.c_str());
-
-	 if (NewFileVer(Ver,List) == false)
-	    return _error->Error(_("Error occurred while processing %s (NewFileVer1)"),
-				 PackageName.c_str());
-	 
-	 // Read only a single record and return
-	 if (OutVer != 0)
-	 {
-	    *OutVer = Ver;
-	    FoundFileDeps |= List.HasFileDeps();
-	    return true;
-	 }
-	 
-	 continue;
-      }      
-
-      // Skip to the end of the same version set.
-      if (Res == 0)
-      {
-	 for (; Ver.end() == false; LastVer = &Ver->NextVer, Ver++)
-	 {
-	    Res = Cache.VS->CmpVersion(Version,Ver.VerStr());
-	    if (Res != 0)
-	       break;
-	 }
-      }
-
-      // Add a new version
-      *LastVer = NewVersion(Ver,Version,*LastVer);
-      Ver->ParentPkg = Pkg.Index();
-      Ver->Hash = Hash;
-
-      if (List.NewVersion(Ver) == false)
-	 return _error->Error(_("Error occurred while processing %s (NewVersion1)"),
-			      PackageName.c_str());
-
-      if (List.UsePackage(Pkg,Ver) == false)
-	 return _error->Error(_("Error occurred while processing %s (UsePackage3)"),
-			      PackageName.c_str());
-      
-      if (NewFileVer(Ver,List) == false)
-	 return _error->Error(_("Error occurred while processing %s (NewVersion2)"),
-			      PackageName.c_str());
-
-      // Read only a single record and return
-      if (OutVer != 0)
-      {
-	 *OutVer = Ver;
-	 FoundFileDeps |= List.HasFileDeps();
-	 return true;
-      }      
-
-      /* Record the Description data. Description data always exist in
-	 Packages and Translation-* files. */
-      pkgCache::DescIterator Desc = Ver.DescriptionList();
-      map_ptrloc *LastDesc = &Ver->DescriptionList;
-      
-      // Skip to the end of description set
-      for (; Desc.end() == false; LastDesc = &Desc->NextDesc, Desc++);
-
-      // Add new description
-      *LastDesc = NewDescription(Desc, List.DescriptionLanguage(), List.Description_md5(), *LastDesc);
-      Desc->ParentPkg = Pkg.Index();
-
-      if (NewFileDesc(Desc,List) == false)
-	 return _error->Error(_("Error occurred while processing %s (NewFileDesc2)"),PackageName.c_str());
-   }
-
-   FoundFileDeps |= List.HasFileDeps();
-
-   return true;
+	List.Owner = this;
+
+	unsigned int Counter = 0;
+	while (List.Step() == true)
+	{
+		// Get a pointer to the package structure
+		string PackageName = List.Package();
+		if (PackageName.empty() == true)
+			return false;
+
+		pkgCache::PkgIterator Pkg;
+		if (NewPackage(Pkg,PackageName) == false)
+			return _error->Error(_("Error occurred while processing %s (NewPackage)"),PackageName.c_str());
+		Counter++;
+		if (Counter % 100 == 0 && Progress != 0)
+			Progress->Progress(List.Offset());
+
+		/* Get a pointer to the version structure. We know the list is sorted
+		   so we use that fact in the search. Insertion of new versions is
+		   done with correct sorting */
+		string Version = List.Version();
+		if (Version.empty() == true)
+		{
+			// we first process the package, then the descriptions
+			// (this has the bonus that we get MMap error when we run out
+			//  of MMap space)
+			if (List.UsePackage(Pkg,pkgCache::VerIterator(Cache)) == false)
+				return _error->Error(_("Error occurred while processing %s (UsePackage1)"),
+						PackageName.c_str());
+
+			// Find the right version to write the description
+			MD5SumValue CurMd5 = List.Description_md5();
+			pkgCache::VerIterator Ver = Pkg.VersionList();
+			pkgCache::Version** LastVer = &Pkg->VersionList;
+
+			for (; Ver.end() == false; LastVer = &Ver->NextVer, Ver++) 
+			{
+				pkgCache::DescIterator Desc = Ver.DescriptionList();
+				pkgCache::Description** LastDesc = &Ver->DescriptionList;
+
+				// don't add a new description if we have one for the given
+				// md5 && language
+				for ( ; Desc.end() == false; LastDesc = &Desc->NextDesc, Desc++)
+					if (MD5SumValue(Desc.md5()) == CurMd5 && 
+							Desc.LanguageCode() == List.DescriptionLanguage())
+					{
+						continue;
+					}
+
+				for (Desc = Ver.DescriptionList();
+						Desc.end() == false; 
+						LastDesc = &Desc->NextDesc, Desc++)
+				{
+					if (MD5SumValue(Desc.md5()) == CurMd5) 
+					{
+						// Add new description
+						*LastDesc = NewDescription(Desc, List.DescriptionLanguage(), CurMd5, *LastDesc);
+						Desc->ParentPkg = Pkg;
+
+						if (NewFileDesc(Desc,List) == false)
+							return _error->Error(_("Error occurred while processing %s (NewFileDesc1)"),PackageName.c_str());
+						break;
+					}
+				}
+			}
+
+			continue;
+		}
+
+		pkgCache::VerIterator Ver = Pkg.VersionList();
+		pkgCache::Version** LastVer = &Pkg->VersionList;
+		int Res = 1;
+		for (; Ver.end() == false; LastVer = &Ver->NextVer, Ver++)
+		{
+			Res = Cache.VS->CmpVersion(Version.c_str(),Ver.VerStr());
+			if (Res >= 0)
+				break;
+		}
+
+		/* We already have a version for this item, record that we
+		   saw it */
+		unsigned long Hash = List.VersionHash();
+		if (Res == 0 && Ver->Hash == Hash)
+		{
+			if (List.UsePackage(Pkg,Ver) == false)
+				return _error->Error(_("Error occurred while processing %s (UsePackage2)"),
+						PackageName.c_str());
+
+			if (NewFileVer(Ver,List) == false)
+				return _error->Error(_("Error occurred while processing %s (NewFileVer1)"),
+						PackageName.c_str());
+
+			// Read only a single record and return
+			if (OutVer != 0)
+			{
+				*OutVer = Ver;
+				FoundFileDeps |= List.HasFileDeps();
+				return true;
+			}
+
+			continue;
+		}
+
+		// Skip to the end of the same version set.
+		if (Res == 0)
+		{
+			for (; Ver.end() == false; LastVer = &Ver->NextVer, Ver++)
+			{
+				Res = Cache.VS->CmpVersion(Version.c_str(),Ver.VerStr());
+				if (Res != 0)
+					break;
+			}
+		}
+
+		// Add a new version
+		*LastVer = NewVersion(Ver,Version,*LastVer);
+		Ver->ParentPkg = Pkg;
+		Ver->Hash = Hash;
+
+		if (List.NewVersion(Ver) == false)
+			return _error->Error(_("Error occurred while processing %s (NewVersion1)"),
+					PackageName.c_str());
+
+		if (List.UsePackage(Pkg,Ver) == false)
+			return _error->Error(_("Error occurred while processing %s (UsePackage3)"),
+					PackageName.c_str());
+
+		if (NewFileVer(Ver,List) == false)
+			return _error->Error(_("Error occurred while processing %s (NewVersion2)"),
+					PackageName.c_str());
+
+		// Read only a single record and return
+		if (OutVer != 0)
+		{
+			*OutVer = Ver;
+			FoundFileDeps |= List.HasFileDeps();
+			return true;
+		}
+
+		/* Record the Description data. Description data always exist in
+		   Packages and Translation-* files. */
+		pkgCache::DescIterator Desc = Ver.DescriptionList();
+		pkgCache::Description** LastDesc = &Ver->DescriptionList;
+
+		// Skip to the end of description set
+		for (; Desc.end() == false; LastDesc = &Desc->NextDesc, Desc++);
+
+		// Add new description
+		*LastDesc = NewDescription(Desc, List.DescriptionLanguage(), List.Description_md5(), *LastDesc);
+		Desc->ParentPkg = Pkg;
+
+		if (NewFileDesc(Desc,List) == false)
+			return _error->Error(_("Error occurred while processing %s (NewFileDesc2)"),PackageName.c_str());
+	}
+
+	FoundFileDeps |= List.HasFileDeps();
+
+	return true;
 }
 									/*}}}*/
 // CacheGenerator::MergeFileProvides - Merge file provides   		/*{{{*/
@@ -318,11 +295,9 @@
       return true;
 
    // Get a structure
-   unsigned long Package = Map.Allocate(sizeof(pkgCache::Package));
-   if (Package == 0)
-      return false;
+   pkgCache::Package* Package = new pkgCache::Package;
    
-   Pkg = pkgCache::PkgIterator(Cache,Cache.PkgP + Package);
+   Pkg = pkgCache::PkgIterator(Cache, Package);
    
    // Insert it into the hash table
    unsigned long Hash = Cache.Hash(Name);
@@ -330,9 +305,7 @@
    Cache.HeaderP->HashTable[Hash] = Package;
    
    // Set the name and the ID
-   Pkg->Name = Map.WriteString(Name);
-   if (Pkg->Name == 0)
-      return false;
+   Pkg->Name = WriteString(Name);
    Pkg->ID = Cache.HeaderP->PackageCount++;
    
    return true;
@@ -348,19 +321,17 @@
       return true;
    
    // Get a structure
-   unsigned long VerFile = Map.Allocate(sizeof(pkgCache::VerFile));
-   if (VerFile == 0)
-      return 0;
-   
-   pkgCache::VerFileIterator VF(Cache,Cache.VerFileP + VerFile);
-   VF->File = CurrentFile - Cache.PkgFileP;
+   pkgCache::VerFile* VerFile = new pkgCache::VerFile;
+
+   pkgCache::VerFileIterator VF(Cache, VerFile);
+   VF->File = CurrentFile;
    
    // Link it to the end of the list
-   map_ptrloc *Last = &Ver->FileList;
+   pkgCache::VerFile** Last = &Ver->FileList;
    for (pkgCache::VerFileIterator V = Ver.FileList(); V.end() == false; V++)
       Last = &V->NextFile;
    VF->NextFile = *Last;
-   *Last = VF.Index();
+   *Last = VF;
    
    VF->Offset = List.Offset();
    VF->Size = List.Size();
@@ -374,20 +345,18 @@
 // CacheGenerator::NewVersion - Create a new Version 			/*{{{*/
 // ---------------------------------------------------------------------
 /* This puts a version structure in the linked list */
-unsigned long pkgCacheGenerator::NewVersion(pkgCache::VerIterator &Ver,
+pkgCache::Version* pkgCacheGenerator::NewVersion(pkgCache::VerIterator &Ver,
 					    const string &VerStr,
-					    unsigned long Next)
+					    pkgCache::Version* Next)
 {
    // Get a structure
-   unsigned long Version = Map.Allocate(sizeof(pkgCache::Version));
-   if (Version == 0)
-      return 0;
+	pkgCache::Version* Version = new pkgCache::Version;
    
    // Fill it in
-   Ver = pkgCache::VerIterator(Cache,Cache.VerP + Version);
+   Ver = pkgCache::VerIterator(Cache, Version);
    Ver->NextVer = Next;
    Ver->ID = Cache.HeaderP->VersionCount++;
-   Ver->VerStr = Map.WriteString(VerStr);
+   Ver->VerStr = WriteString(VerStr);
    if (Ver->VerStr == 0)
       return 0;
    
@@ -404,20 +373,18 @@
       return true;
    
    // Get a structure
-   unsigned long DescFile = Map.Allocate(sizeof(pkgCache::DescFile));
-   if (DescFile == 0)
-      return 0;
+   pkgCache::DescFile* DescFile = new pkgCache::DescFile;
 
-   pkgCache::DescFileIterator DF(Cache,Cache.DescFileP + DescFile);
-   DF->File = CurrentFile - Cache.PkgFileP;
+   pkgCache::DescFileIterator DF(Cache, DescFile);
+   DF->File = CurrentFile;
 
    // Link it to the end of the list
-   map_ptrloc *Last = &Desc->FileList;
+   pkgCache::DescFile** Last = &Desc->FileList;
    for (pkgCache::DescFileIterator D = Desc.FileList(); D.end() == false; D++)
       Last = &D->NextFile;
 
    DF->NextFile = *Last;
-   *Last = DF.Index();
+   *Last = DF;
    
    DF->Offset = List.Offset();
    DF->Size = List.Size();
@@ -431,22 +398,20 @@
 // CacheGenerator::NewDescription - Create a new Description		/*{{{*/
 // ---------------------------------------------------------------------
 /* This puts a description structure in the linked list */
-map_ptrloc pkgCacheGenerator::NewDescription(pkgCache::DescIterator &Desc,
-					    const string &Lang, 
-                                            const MD5SumValue &md5sum,
-					    map_ptrloc Next)
+pkgCache::Description* pkgCacheGenerator::NewDescription(pkgCache::DescIterator &Desc,
+		const string &Lang, 
+		const MD5SumValue &md5sum,
+		pkgCache::Description* Next)
 {
    // Get a structure
-   map_ptrloc Description = Map.Allocate(sizeof(pkgCache::Description));
-   if (Description == 0)
-      return 0;
+	pkgCache::Description* Description = new pkgCache::Description;
 
    // Fill it in
-   Desc = pkgCache::DescIterator(Cache,Cache.DescP + Description);
+   Desc = pkgCache::DescIterator(Cache, Description);
    Desc->NextDesc = Next;
    Desc->ID = Cache.HeaderP->DescriptionCount++;
-   Desc->language_code = Map.WriteString(Lang);
-   Desc->md5sum = Map.WriteString(md5sum.Value());
+   Desc->language_code = WriteString(Lang);
+   Desc->md5sum = WriteString(md5sum.Value());
 
    return Description;
 }
@@ -464,13 +429,11 @@
    pkgCache &Cache = Owner->Cache;
    
    // Get a structure
-   unsigned long Dependency = Owner->Map.Allocate(sizeof(pkgCache::Dependency));
-   if (Dependency == 0)
-      return false;
+   pkgCache::Dependency* Dependency = new pkgCache::Dependency;
    
    // Fill it in
-   pkgCache::DepIterator Dep(Cache,Cache.DepP + Dependency);
-   Dep->ParentVer = Ver.Index();
+   pkgCache::DepIterator Dep(Cache, Dependency);
+   Dep->ParentVer = &*Ver;
    Dep->Type = Type;
    Dep->CompareOp = Op;
    Dep->ID = Cache.HeaderP->DependsCount++;
@@ -492,9 +455,9 @@
    }
       
    // Link it to the package
-   Dep->Package = Pkg.Index();
+   Dep->Package = Pkg;
    Dep->NextRevDepends = Pkg->RevDepends;
-   Pkg->RevDepends = Dep.Index();
+   Pkg->RevDepends = Dep;
    
    /* Link it to the version (at the end of the list)
       Caching the old end point speeds up generation substantially */
@@ -511,7 +474,7 @@
       FoundFileDeps = true;
    
    Dep->NextDepends = *OldDepLast;
-   *OldDepLast = Dep.Index();
+   *OldDepLast = Dep;
    OldDepLast = &Dep->NextDepends;
 
    return true;
@@ -531,16 +494,14 @@
       return true;
    
    // Get a structure
-   unsigned long Provides = Owner->Map.Allocate(sizeof(pkgCache::Provides));
-   if (Provides == 0)
-      return false;
+   pkgCache::Provides* Provides = new pkgCache::Provides;
    Cache.HeaderP->ProvidesCount++;
    
    // Fill it in
-   pkgCache::PrvIterator Prv(Cache,Cache.ProvideP + Provides,Cache.PkgP);
-   Prv->Version = Ver.Index();
+   pkgCache::PrvIterator Prv(Cache,Provides,(pkgCache::Package*)NULL);
+   Prv->Version = Ver;
    Prv->NextPkgProv = Ver->ProvidesList;
-   Ver->ProvidesList = Prv.Index();
+   Ver->ProvidesList = Prv;
    if (Version.empty() == false && (Prv->ProvideVersion = WriteString(Version)) == 0)
       return false;
    
@@ -550,9 +511,9 @@
       return false;
    
    // Link it to the package
-   Prv->ParentPkg = Pkg.Index();
+   Prv->ParentPkg = Pkg;
    Prv->NextProvides = Pkg->ProvidesList;
-   Pkg->ProvidesList = Prv.Index();
+   Pkg->ProvidesList = Prv;
    
    return true;
 }
@@ -566,24 +527,19 @@
 				   unsigned long Flags)
 {
    // Get some space for the structure
-   CurrentFile = Cache.PkgFileP + Map.Allocate(sizeof(*CurrentFile));
-   if (CurrentFile == Cache.PkgFileP)
-      return false;
+   CurrentFile = new pkgCache::PackageFile;
    
    // Fill it in
-   CurrentFile->FileName = Map.WriteString(File);
+   CurrentFile->FileName = WriteString(File);
    CurrentFile->Site = WriteUniqString(Site);
    CurrentFile->NextFile = Cache.HeaderP->FileList;
    CurrentFile->Flags = Flags;
    CurrentFile->ID = Cache.HeaderP->PackageFileCount;
    CurrentFile->IndexType = WriteUniqString(Index.GetType()->Label);
    PkgFileName = File;
-   Cache.HeaderP->FileList = CurrentFile - Cache.PkgFileP;
+   Cache.HeaderP->FileList = CurrentFile;
    Cache.HeaderP->PackageFileCount++;
 
-   if (CurrentFile->FileName == 0)
-      return false;
-   
    if (Progress != 0)
       Progress->SubProgress(Index.Size());
    return true;
@@ -592,25 +548,25 @@
 // CacheGenerator::WriteUniqueString - Insert a unique string		/*{{{*/
 // ---------------------------------------------------------------------
 /* This is used to create handles to strings. Given the same text it
-   always returns the same number */
-unsigned long pkgCacheGenerator::WriteUniqString(const char *S,
+   always returns the same number
+   TODO: Rewrite to full-functional list-based hash */
+char* pkgCacheGenerator::WriteUniqString(const char *S,
 						 unsigned int Size)
 {
    /* We use a very small transient hash table here, this speeds up generation
       by a fair amount on slower machines */
    pkgCache::StringItem *&Bucket = UniqHash[(S[0]*5 + S[1]) % _count(UniqHash)];
    if (Bucket != 0 && 
-       stringcmp(S,S+Size,Cache.StrP + Bucket->String) == 0)
+       stringcmp(S,S+Size,Bucket->String) == 0)
       return Bucket->String;
    
    // Search for an insertion point
-   pkgCache::StringItem *I = Cache.StringItemP + Cache.HeaderP->StringList;
+   pkgCache::StringItem *I = Cache.StringItemStartP;
    int Res = 1;
-   map_ptrloc *Last = &Cache.HeaderP->StringList;
-   for (; I != Cache.StringItemP; Last = &I->NextItem, 
-        I = Cache.StringItemP + I->NextItem)
+   pkgCache::StringItem** Last = &Cache.StringItemStartP;
+   for (; I != NULL; Last = &I->NextItem, I = I->NextItem)
    {
-      Res = stringcmp(S,S+Size,Cache.StrP + I->String);
+      Res = stringcmp(S,S+Size,I->String);
       if (Res >= 0)
 	 break;
    }
@@ -622,87 +578,16 @@
       return I->String;
    }
    
-   // Get a structure
-   unsigned long Item = Map.Allocate(sizeof(pkgCache::StringItem));
-   if (Item == 0)
-      return 0;
-
    // Fill in the structure
-   pkgCache::StringItem *ItemP = Cache.StringItemP + Item;
-   ItemP->NextItem = I - Cache.StringItemP;
-   *Last = Item;
-   ItemP->String = Map.WriteString(S,Size);
-   if (ItemP->String == 0)
-      return 0;
+   pkgCache::StringItem *ItemP = new pkgCache::StringItem;
+   ItemP->NextItem = I;
+   *Last = ItemP;
+   ItemP->String = WriteString(S,Size);
    
    Bucket = ItemP;
    return ItemP->String;
 }
 									/*}}}*/
-
-// CheckValidity - Check that a cache is up-to-date			/*{{{*/
-// ---------------------------------------------------------------------
-/* This just verifies that each file in the list of index files exists,
-   has matching attributes with the cache and the cache does not have
-   any extra files. */
-static bool CheckValidity(const string &CacheFile, FileIterator Start, 
-                          FileIterator End,MMap **OutMap = 0)
-{
-   // No file, certainly invalid
-   if (CacheFile.empty() == true || FileExists(CacheFile) == false)
-      return false;
-   
-   // Map it
-   FileFd CacheF(CacheFile,FileFd::ReadOnly);
-   SPtr<MMap> Map = new MMap(CacheF,MMap::Public | MMap::ReadOnly);
-   pkgCache Cache(Map);
-   if (_error->PendingError() == true || Map->Size() == 0)
-   {
-      _error->Discard();
-      return false;
-   }
-   
-   /* Now we check every index file, see if it is in the cache,
-      verify the IMS data and check that it is on the disk too.. */
-   SPtrArray<bool> Visited = new bool[Cache.HeaderP->PackageFileCount];
-   memset(Visited,0,sizeof(*Visited)*Cache.HeaderP->PackageFileCount);
-   for (; Start != End; Start++)
-   {      
-      if ((*Start)->HasPackages() == false)
-	 continue;
-    
-      if ((*Start)->Exists() == false)
-      {
-#if 0 // mvo: we no longer give a message here (Default Sources spec)
-	 _error->WarningE("stat",_("Couldn't stat source package list %s"),
-			  (*Start)->Describe().c_str());
-#endif
-	 continue;
-      }
-
-      // FindInCache is also expected to do an IMS check.
-      pkgCache::PkgFileIterator File = (*Start)->FindInCache(Cache);
-      if (File.end() == true)
-	 return false;
-
-      Visited[File->ID] = true;
-   }
-   
-   for (unsigned I = 0; I != Cache.HeaderP->PackageFileCount; I++)
-      if (Visited[I] == false)
-	 return false;
-   
-   if (_error->PendingError() == true)
-   {
-      _error->Discard();
-      return false;
-   }
-   
-   if (OutMap != 0)
-      *OutMap = Map.UnGuard();
-   return true;
-}
-									/*}}}*/
 // ComputeSize - Compute the total size of a bunch of files		/*{{{*/
 // ---------------------------------------------------------------------
 /* Size is kind of an abstract notion that is only used for the progress
@@ -772,16 +657,9 @@
 // MakeStatusCache - Construct the status cache				/*{{{*/
 // ---------------------------------------------------------------------
 /* This makes sure that the status cache (the cache that has all 
-   index files from the sources list and all local ones) is ready
-   to be mmaped. If OutMap is not zero then a MMap object representing
-   the cache will be stored there. This is pretty much mandetory if you
-   are using AllowMem. AllowMem lets the function be run as non-root
-   where it builds the cache 'fast' into a memory buffer. */
-bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress,
-			MMap **OutMap,bool AllowMem)
+   index files from the sources list and all local ones) is ready */
+bool pkgMakeStatusCache(pkgCache& Cache, pkgSourceList &List,OpProgress &Progress)
 {
-   unsigned long MapSize = _config->FindI("APT::Cache-Limit",24*1024*1024);
-   
    vector<pkgIndexFile *> Files;
    for (vector<metaIndex *>::const_iterator i = List.begin();
         i != List.end();
@@ -798,106 +676,25 @@
    if (_system->AddStatusFiles(Files) == false)
       return false;
    
-   // Decide if we can write to the files..
-   string CacheFile = _config->FindFile("Dir::Cache::pkgcache");
-   string SrcCacheFile = _config->FindFile("Dir::Cache::srcpkgcache");
-   
-   // Decide if we can write to the cache
-   bool Writeable = false;
-   if (CacheFile.empty() == false)
-      Writeable = access(flNotFile(CacheFile).c_str(),W_OK) == 0;
-   else
-      if (SrcCacheFile.empty() == false)
-	 Writeable = access(flNotFile(SrcCacheFile).c_str(),W_OK) == 0;
-   
-   if (Writeable == false && AllowMem == false && CacheFile.empty() == false)
-      return _error->Error(_("Unable to write to %s"),flNotFile(CacheFile).c_str());
-   
    Progress.OverallProgress(0,1,1,_("Reading package lists"));
    
-   // Cache is OK, Fin.
-   if (CheckValidity(CacheFile,Files.begin(),Files.end(),OutMap) == true)
-   {
-      Progress.OverallProgress(1,1,1,_("Reading package lists"));
-      return true;
-   }
-   
    /* At this point we know we need to reconstruct the package cache,
       begin. */
-   SPtr<FileFd> CacheF;
-   SPtr<DynamicMMap> Map;
-   if (Writeable == true && CacheFile.empty() == false)
-   {
-      unlink(CacheFile.c_str());
-      CacheF = new FileFd(CacheFile,FileFd::WriteEmpty);
-      fchmod(CacheF->Fd(),0644);
-      Map = new DynamicMMap(*CacheF,MMap::Public,MapSize);
-      if (_error->PendingError() == true)
-	 return false;
-   }
-   else
-   {
-      // Just build it in memory..
-      Map = new DynamicMMap(MMap::Public,MapSize);
-   }
    
    // Lets try the source cache.
    unsigned long CurrentSize = 0;
    unsigned long TotalSize = 0;
-   if (CheckValidity(SrcCacheFile,Files.begin(),
-		     Files.begin()+EndOfSource) == true)
-   {
-      // Preload the map with the source cache
-      FileFd SCacheF(SrcCacheFile,FileFd::ReadOnly);
-      if (SCacheF.Read((unsigned char *)Map->Data() + Map->RawAllocate(SCacheF.Size()),
-		       SCacheF.Size()) == false)
-	 return false;
-
-      TotalSize = ComputeSize(Files.begin()+EndOfSource,Files.end());
-      
-      // Build the status cache
-      pkgCacheGenerator Gen(Map.Get(),&Progress);
-      if (_error->PendingError() == true)
-	 return false;
-      if (BuildCache(Gen,Progress,CurrentSize,TotalSize,
-		     Files.begin()+EndOfSource,Files.end()) == false)
-	 return false;
-   }
-   else
    {
       TotalSize = ComputeSize(Files.begin(),Files.end());
       
       // Build the source cache
-      pkgCacheGenerator Gen(Map.Get(),&Progress);
+      pkgCacheGenerator Gen(Cache, &Progress);
       if (_error->PendingError() == true)
 	 return false;
       if (BuildCache(Gen,Progress,CurrentSize,TotalSize,
 		     Files.begin(),Files.begin()+EndOfSource) == false)
 	 return false;
       
-      // Write it back
-      if (Writeable == true && SrcCacheFile.empty() == false)
-      {
-	 FileFd SCacheF(SrcCacheFile,FileFd::WriteEmpty);
-	 if (_error->PendingError() == true)
-	    return false;
-	 
-	 fchmod(SCacheF.Fd(),0644);
-	 
-	 // Write out the main data
-	 if (SCacheF.Write(Map->Data(),Map->Size()) == false)
-	    return _error->Error(_("IO Error saving source cache"));
-	 SCacheF.Sync();
-	 
-	 // Write out the proper header
-	 Gen.GetCache().HeaderP->Dirty = false;
-	 if (SCacheF.Seek(0) == false ||
-	     SCacheF.Write(Map->Data(),sizeof(*Gen.GetCache().HeaderP)) == false)
-	    return _error->Error(_("IO Error saving source cache"));
-	 Gen.GetCache().HeaderP->Dirty = true;
-	 SCacheF.Sync();
-      }
-      
       // Build the status cache
       if (BuildCache(Gen,Progress,CurrentSize,TotalSize,
 		     Files.begin()+EndOfSource,Files.end()) == false)
@@ -906,35 +703,20 @@
 
    if (_error->PendingError() == true)
       return false;
-   if (OutMap != 0)
-   {
-      if (CacheF != 0)
-      {
-	 delete Map.UnGuard();
-	 *OutMap = new MMap(*CacheF,MMap::Public | MMap::ReadOnly);
-      }
-      else
-      {
-	 *OutMap = Map.UnGuard();
-      }      
-   }
-   
+
    return true;
 }
 									/*}}}*/
 // MakeOnlyStatusCache - Build a cache with just the status files	/*{{{*/
 // ---------------------------------------------------------------------
 /* */
-bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap)
+bool pkgMakeOnlyStatusCache(pkgCache& Cache, OpProgress &Progress)
 {
-   unsigned long MapSize = _config->FindI("APT::Cache-Limit",20*1024*1024);
    vector<pkgIndexFile *> Files;
    unsigned long EndOfSource = Files.size();
    if (_system->AddStatusFiles(Files) == false)
       return false;
    
-   SPtr<DynamicMMap> Map;   
-   Map = new DynamicMMap(MMap::Public,MapSize);
    unsigned long CurrentSize = 0;
    unsigned long TotalSize = 0;
    
@@ -942,7 +724,7 @@
    
    // Build the status cache
    Progress.OverallProgress(0,1,1,_("Reading package lists"));
-   pkgCacheGenerator Gen(Map.Get(),&Progress);
+   pkgCacheGenerator Gen(Cache, &Progress);
    if (_error->PendingError() == true)
       return false;
    if (BuildCache(Gen,Progress,CurrentSize,TotalSize,
@@ -951,7 +733,6 @@
    
    if (_error->PendingError() == true)
       return false;
-   *OutMap = Map.UnGuard();
    
    return true;
 }

=== modified file 'apt-pkg/pkgcachegen.h'
--- apt-pkg/pkgcachegen.h	2008-11-16 13:58:02 +0000
+++ apt-pkg/pkgcachegen.h	2008-11-29 21:39:59 +0000
@@ -25,7 +25,6 @@
 
 class pkgSourceList;
 class OpProgress;
-class MMap;
 class pkgIndexFile;
 
 class pkgCacheGenerator
@@ -41,8 +40,7 @@
    
    protected:
    
-   DynamicMMap &Map;
-   pkgCache Cache;
+   pkgCache& Cache;
    OpProgress *Progress;
    
    string PkgFileName;
@@ -54,13 +52,16 @@
    bool NewPackage(pkgCache::PkgIterator &Pkg,const string &PkgName);
    bool NewFileVer(pkgCache::VerIterator &Ver,ListParser &List);
    bool NewFileDesc(pkgCache::DescIterator &Desc,ListParser &List);
-   unsigned long NewVersion(pkgCache::VerIterator &Ver,const string &VerStr,unsigned long Next);
-   map_ptrloc NewDescription(pkgCache::DescIterator &Desc,const string &Lang,const MD5SumValue &md5sum,map_ptrloc Next);
+   pkgCache::Version* NewVersion(pkgCache::VerIterator &Ver,const string &VerStr,pkgCache::Version* Next);
+   pkgCache::Description* NewDescription(pkgCache::DescIterator &Desc,const string &Lang,const MD5SumValue &md5sum,pkgCache::Description* Next);
 
    public:
 
-   unsigned long WriteUniqString(const char *S,unsigned int Size);
-   inline unsigned long WriteUniqString(const string &S) {return WriteUniqString(S.c_str(),S.length());};
+   char* WriteUniqString(const char *S,unsigned int Size);
+   inline char* WriteUniqString(const string &S) {return WriteUniqString(S.c_str(),S.length());};
+   char* WriteString(const char *S,unsigned int Size) {return strndup(S, Size);};
+   inline char* WriteString(const string &S) {return WriteString(S.c_str(),S.length());};
+
 
    void DropProgress() {Progress = 0;};
    bool SelectFile(const string &File,const string &Site,pkgIndexFile const &Index,
@@ -73,29 +74,29 @@
    bool HasFileDeps() {return FoundFileDeps;};
    bool MergeFileProvides(ListParser &List);
       
-   pkgCacheGenerator(DynamicMMap *Map,OpProgress *Progress);
+   pkgCacheGenerator(pkgCache& Cache, OpProgress *Progress);
    ~pkgCacheGenerator();
 };
 
 // This is the abstract package list parser class.
 class pkgCacheGenerator::ListParser
 {
-   pkgCacheGenerator *Owner;
+   pkgCacheGenerator* Owner;
    friend class pkgCacheGenerator;
    
    // Some cache items
    pkgCache::VerIterator OldDepVer;
-   map_ptrloc *OldDepLast;
+   pkgCache::Dependency** OldDepLast;
 
    // Flag file dependencies
    bool FoundFileDeps;
       
    protected:
 
-   inline unsigned long WriteUniqString(string S) {return Owner->WriteUniqString(S);};
-   inline unsigned long WriteUniqString(const char *S,unsigned int Size) {return Owner->WriteUniqString(S,Size);};
-   inline unsigned long WriteString(const string &S) {return Owner->Map.WriteString(S);};
-   inline unsigned long WriteString(const char *S,unsigned int Size) {return Owner->Map.WriteString(S,Size);};
+   inline char* WriteUniqString(string S) {return Owner->WriteUniqString(S);};
+   inline char* WriteUniqString(const char *S,unsigned int Size) {return Owner->WriteUniqString(S,Size);};
+   inline char* WriteString(const string &S) {return Owner->WriteString(S);};
+   inline char* WriteString(const char *S,unsigned int Size) {return Owner->WriteString(S,Size);};
    bool NewDepends(pkgCache::VerIterator Ver,const string &Package,
 		   const string &Version,unsigned int Op,
 		   unsigned int Type);
@@ -127,20 +128,16 @@
    virtual ~ListParser() {};
 };
 
-bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress,
-			MMap **OutMap = 0,bool AllowMem = false);
-bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap);
+bool pkgMakeStatusCache(pkgCache& Cache, pkgSourceList &List,OpProgress &Progress);
+bool pkgMakeOnlyStatusCache(pkgCache& Cache, OpProgress &Progress);
 
 #ifdef APT_COMPATIBILITY
 #if APT_COMPATIBILITY != 986
 #warning "Using APT_COMPATIBILITY"
 #endif
-MMap *pkgMakeStatusCacheMem(pkgSourceList &List,OpProgress &Progress)
+void pkgMakeStatusCacheMem(pkgCache& Cache, pkgSourceList &List,OpProgress &Progress)
 {
-   MMap *Map = 0;
-   if (pkgMakeStatusCache(List,Progress,&Map,true) == false)
-      return 0;
-   return Map;
+	pkgMakeStatusCache(Cache, List, Progress);
 }
 #endif
 

=== modified file 'apt-pkg/version.h'
--- apt-pkg/version.h	2008-11-16 13:58:02 +0000
+++ apt-pkg/version.h	2008-11-29 23:52:26 +0000
@@ -37,22 +37,16 @@
    const char *Label;
    
    // Compare versions..
-   virtual int DoCmpVersion(const char *A,const char *Aend,
-			  const char *B,const char *Bend) = 0;   
+   virtual int CmpVersion(const char *A, const char *B) = 0;   
 
    virtual bool CheckDep(const char *PkgVer,int Op,const char *DepVer) = 0;
-   virtual int DoCmpReleaseVer(const char *A,const char *Aend,
-			       const char *B,const char *Bend) = 0;
+   virtual int CmpReleaseVer(const char *A, const char *B) = 0;
    virtual string UpstreamVersion(const char *A) = 0;
    
    // See if the given VS is compatible with this one.. 
    virtual bool TestCompatibility(pkgVersioningSystem const &Against) 
                 {return this == &Against;};
 
-   // Shortcuts
-   APT_MKSTRCMP(CmpVersion,DoCmpVersion);
-   APT_MKSTRCMP(CmpReleaseVer,DoCmpReleaseVer);
-   
    pkgVersioningSystem();
    virtual ~pkgVersioningSystem() {};
 };

=== modified file 'cmdline/apt-cache.cc'
--- cmdline/apt-cache.cc	2008-11-20 21:22:51 +0000
+++ cmdline/apt-cache.cc	2008-11-29 21:43:33 +0000
@@ -304,17 +304,6 @@
    cout << _("Total Provides mappings: ") << Cache.Head().ProvidesCount << " (" <<
       SizeToStr(Cache.Head().ProvidesCount*Cache.Head().ProvidesSz) << ')' << endl;
    
-   // String list stats
-   unsigned long Size = 0;
-   unsigned long Count = 0;
-   for (pkgCache::StringItem *I = Cache.StringItemP + Cache.Head().StringList;
-        I!= Cache.StringItemP; I = Cache.StringItemP + I->NextItem)
-   {
-      Count++;
-      Size += strlen(Cache.StrP + I->String) + 1;
-   }
-   cout << _("Total globbed strings: ") << Count << " (" << SizeToStr(Size) << ')' << endl;
-
    unsigned long DepVerSize = 0;
    for (pkgCache::PkgIterator P = Cache.PkgBegin(); P.end() == false; P++)
    {
@@ -329,19 +318,13 @@
    }
    cout << _("Total dependency version space: ") << SizeToStr(DepVerSize) << endl;
    
-   unsigned long Slack = 0;
-   for (int I = 0; I != 7; I++)
-      Slack += Cache.Head().Pools[I].ItemSize*Cache.Head().Pools[I].Count;
-   cout << _("Total slack space: ") << SizeToStr(Slack) << endl;
-   
-   unsigned long Total = 0;
-   Total = Slack + Size + Cache.Head().DependsCount*Cache.Head().DependencySz + 
+   size_t Total = Cache.Head().DependsCount*Cache.Head().DependencySz + 
            Cache.Head().VersionCount*Cache.Head().VersionSz +
            Cache.Head().PackageCount*Cache.Head().PackageSz + 
            Cache.Head().VerFileCount*Cache.Head().VerFileSz +
            Cache.Head().ProvidesCount*Cache.Head().ProvidesSz;
    cout << _("Total space accounted for: ") << SizeToStr(Total) << endl;
-   
+
    return true;
 }
 									/*}}}*/
@@ -465,7 +448,7 @@
    char *Buffer = new char[Cache.HeaderP->MaxVerFileSize+10];
    for (pkgCache::VerFile **J = VFList; *J != 0;)
    {
-      pkgCache::PkgFileIterator File(Cache,(*J)->File + Cache.PkgFileP);
+      pkgCache::PkgFileIterator File(Cache,(*J)->File);
       if (File.IsOk() == false)
       {
 	 _error->Error(_("Package file %s is out of sync."),File.FileName());
@@ -484,7 +467,7 @@
       unsigned long Pos = 0;
       for (; *J != 0; J++)
       {
-	 if ((*J)->File + Cache.PkgFileP != File)
+	 if ((*J)->File != File)
 	    break;
 	 
 	 const pkgCache::VerFile &VF = **J;
@@ -607,7 +590,7 @@
 	    for (pkgCache::Version **I = List; *I != 0; I++)
 	    {
 	       pkgCache::VerIterator V(Cache,*I);
-	       if (V != Cache.VerP + V.ParentPkg()->VersionList ||
+	       if (V != V.ParentPkg()->VersionList ||
 		   V->ParentPkg == D->Package)
 		  continue;
 	       cout << "    " << V.ParentPkg().Name() << endl;
@@ -695,7 +678,7 @@
 	    for (pkgCache::Version **I = List; *I != 0; I++)
 	    {
 	       pkgCache::VerIterator V(Cache,*I);
-	       if (V != Cache.VerP + V.ParentPkg()->VersionList ||
+	       if (V != V.ParentPkg()->VersionList ||
 		   V->ParentPkg == D->Package)
 		  continue;
 	       cout << "    " << V.ParentPkg().Name() << endl;
@@ -1693,19 +1676,6 @@
 }
 
 									/*}}}*/
-// GenCaches - Call the main cache generator				/*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool GenCaches(CommandLine &Cmd)
-{
-   OpTextProgress Progress(*_config);
-   
-   pkgSourceList List;
-   if (List.ReadMainList() == false)
-      return false;   
-   return pkgMakeStatusCache(List,Progress);
-}
-									/*}}}*/
 // ShowHelp - Show a help screen					/*{{{*/
 // ---------------------------------------------------------------------
 /* */
@@ -1771,8 +1741,6 @@
    CommandLine::Args Args[] = {
       {'h',"help","help",0},
       {'v',"version","version",0},
-      {'p',"pkg-cache","Dir::Cache::pkgcache",CommandLine::HasArg},
-      {'s',"src-cache","Dir::Cache::srcpkgcache",CommandLine::HasArg},
       {'q',"quiet","quiet",CommandLine::IntLevel},
       {'i',"important","APT::Cache::Important",0},
       {'f',"full","APT::Cache::ShowFull",0},
@@ -1787,7 +1755,6 @@
       {0,0,0,0}};
    CommandLine::Dispatch CmdsA[] = {{"help",&ShowHelp},
                                     {"add",&DoAdd},
-                                    {"gencaches",&GenCaches},
                                     {"showsrc",&ShowSrcPackage},
                                     {0,0}};
    CommandLine::Dispatch CmdsB[] = {{"showpkg",&DumpPackage},
@@ -1836,31 +1803,18 @@
 
    if (CmdL.DispatchArg(CmdsA,false) == false && _error->PendingError() == false)
    { 
-      MMap *Map = 0;
-      if (_config->FindB("APT::Cache::Generate",true) == false)
-      {
-	 Map = new MMap(*new FileFd(_config->FindFile("Dir::Cache::pkgcache"),
-				    FileFd::ReadOnly),MMap::Public|MMap::ReadOnly);
-      }
-      else
-      {
-	 // Open the cache file
+	 // Generate it and map it
 	 SrcList = new pkgSourceList;
 	 SrcList->ReadMainList();
-
-	 // Generate it and map it
 	 OpProgress Prog;
-	 pkgMakeStatusCache(*SrcList,Prog,&Map,true);
-      }
+	 GCache = new pkgCache;
+	 pkgMakeStatusCache(*GCache, *SrcList,Prog);
       
       if (_error->PendingError() == false)
       {
-	 pkgCache Cache(Map);   
-	 GCache = &Cache;
 	 if (_error->PendingError() == false)
 	    CmdL.DispatchArg(CmdsB);
       }
-      delete Map;
    }
    
    // Print any errors or warnings found during parsing

=== modified file 'cmdline/apt-extracttemplates.cc'
--- cmdline/apt-extracttemplates.cc	2008-11-20 21:22:51 +0000
+++ cmdline/apt-extracttemplates.cc	2008-11-29 21:45:53 +0000
@@ -293,14 +293,11 @@
 bool Go(CommandLine &CmdL)
 {	
 	// Initialize the apt cache
-	MMap *Map = 0;
 	pkgSourceList List;
 	List.ReadMainList();
 	OpProgress Prog;
-	pkgMakeStatusCache(List,Prog,&Map,true);
-	if (Map == 0)
-	   return false;
-	DebFile::Cache = new pkgCache(Map);
+	DebFile::Cache = new pkgCache;
+	pkgMakeStatusCache(*DebFile::Cache, List,Prog);
 	if (_error->PendingError() == true)
 		return false;
 
@@ -342,7 +339,6 @@
 	}
 	
 
-	delete Map;
 	delete DebFile::Cache;
 	
 	return !_error->PendingError();

=== modified file 'cmdline/apt-get.cc'
--- cmdline/apt-get.cc	2008-11-20 21:22:51 +0000
+++ cmdline/apt-get.cc	2008-11-30 00:43:13 +0000
@@ -607,7 +607,7 @@
    const pkgCache::Package &A = **(pkgCache::Package **)a;
    const pkgCache::Package &B = **(pkgCache::Package **)b;
 
-   return strcmp(SortCache->StrP + A.Name,SortCache->StrP + B.Name);
+   return strcmp(A.Name,B.Name);
 }
 									/*}}}*/
 // CacheFile::Sort - Sort by name					/*{{{*/
@@ -1303,7 +1303,7 @@
       {
 	 /* Don't want to fall through because we are doing exact version 
 	    matching. */
-	 if (Cache.VS().CmpVersion(VerTag,Ver) != 0)
+	 if (Cache.VS().CmpVersion(VerTag.c_str(),Ver.c_str()) != 0)
 	    continue;
 	 
 	 Last = Parse;
@@ -1312,7 +1312,7 @@
       }
 				  
       // Newer version or an exact match
-      if (Last == 0 || Cache.VS().CmpVersion(Version,Ver) < 0 || 
+      if (Last == 0 || Cache.VS().CmpVersion(Version.c_str(),Ver.c_str()) < 0 || 
 	  (Parse->Package() == Src && IsMatch == false))
       {
 	 IsMatch = Parse->Package() == Src;

=== modified file 'configure.in'
--- configure.in	2008-11-26 20:50:57 +0000
+++ configure.in	2008-11-29 07:57:56 +0000
@@ -18,7 +18,7 @@
 AC_CONFIG_HEADER(include/config.h:buildlib/config.h.in include/apti18n.h:buildlib/apti18n.h.in)
 
 dnl -- SET THIS TO THE RELEASE VERSION --
-AC_DEFINE_UNQUOTED(VERSION,"0.8.0")
+AC_DEFINE_UNQUOTED(VERSION,"0.8.0~jackyf")
 PACKAGE="apt"
 AC_DEFINE_UNQUOTED(PACKAGE,"$PACKAGE")
 AC_SUBST(PACKAGE)

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: