advoid a problem during a crash */
pkgCacheGenerator::~pkgCacheGenerator()
{
- if (_error->PendingError() == true)
+ if (_error->PendingError() == true || Map.validData() == false)
return;
if (Map.Sync() == false)
return;
{
std::string const key(S, Size);
- std::map<std::string,map_stringitem_t> * strings;
+ std::unordered_map<std::string,map_stringitem_t> * strings;
switch(type) {
case MIXED: strings = &strMixed; break;
case PKGNAME: strings = &strPkgNames; break;
default: _error->Fatal("Unknown enum type used for string storage of '%s'", key.c_str()); return 0;
}
- std::map<std::string,map_stringitem_t>::const_iterator const item = strings->find(key);
+ std::unordered_map<std::string,map_stringitem_t>::const_iterator const item = strings->find(key);
if (item != strings->end())
return item->second;
// Map it
FileFd CacheF(CacheFile,FileFd::ReadOnly);
std::unique_ptr<MMap> Map(new MMap(CacheF,0));
+ if (unlikely(Map->validData()) == false)
+ return false;
pkgCache Cache(Map.get());
if (_error->PendingError() || Map->Size() == 0)
{
std::unique_ptr<DynamicMMap> &Map, OpProgress * const Progress, std::string const &FileName)
{
Map.reset(CreateDynamicMMap(NULL, 0));
+ if (unlikely(Map->validData()) == false)
+ return false;
FileFd CacheF(FileName, FileFd::ReadOnly);
if (CacheF.IsOpen() == false || CacheF.Failed())
return false;
Gen.reset(new pkgCacheGenerator(Map.get(),Progress));
return true;
}
-APT_DEPRECATED bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress,
+bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress,
MMap **OutMap, bool AllowMem)
{ return pkgCacheGenerator::MakeStatusCache(List, &Progress, OutMap, AllowMem); }
bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress,
// At this point we know we need to construct something, so get storage ready
std::unique_ptr<DynamicMMap> Map(CreateDynamicMMap(NULL, 0));
+ if (unlikely(Map->validData()) == false)
+ return false;
if (Debug == true)
std::clog << "Open memory Map (not filebased)" << std::endl;
ScopedErrorMerge() { _error->PushToStack(); }
~ScopedErrorMerge() { _error->MergeWithStack(); }
};
-APT_DEPRECATED bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap)
+bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap)
{ return pkgCacheGenerator::MakeOnlyStatusCache(&Progress, OutMap); }
bool pkgCacheGenerator::MakeOnlyStatusCache(OpProgress *Progress,DynamicMMap **OutMap)
{
ScopedErrorMerge sem;
std::unique_ptr<DynamicMMap> Map(CreateDynamicMMap(NULL, 0));
+ if (unlikely(Map->validData()) == false)
+ return false;
map_filesize_t CurrentSize = 0;
map_filesize_t TotalSize = 0;
TotalSize = ComputeSize(NULL, Files.begin(), Files.end());