HashMap: Fix the build with GCC 7.

This commit is contained in:
Augustin Cavalier
2019-02-14 19:52:45 -05:00
parent b6840f3610
commit fc8e5be1c8
2 changed files with 10 additions and 3 deletions
+9 -1
View File
@@ -163,7 +163,7 @@ public:
typedef typename HashMap<Key, Value>::Iterator Iterator; typedef typename HashMap<Key, Value>::Iterator Iterator;
SynchronizedHashMap() : Locker("synchronized hash map") {} SynchronizedHashMap() : Locker("synchronized hash map") {}
~SynchronizedHashMap() { Lock(); } ~SynchronizedHashMap() { Locker::Lock(); }
status_t InitCheck() const status_t InitCheck() const
{ {
@@ -186,6 +186,14 @@ public:
return fMap.Remove(key); return fMap.Remove(key);
} }
Value Remove(Iterator& it)
{
MapLocker locker(this);
if (!locker.IsLocked())
return Value();
return fMap.Remove(it);
}
void Clear() void Clear()
{ {
MapLocker locker(this); MapLocker locker(this);
@@ -85,7 +85,6 @@ BNetworkCookieJar::~BNetworkCookieJar()
PrivateHashMap::Iterator it = fCookieHashMap->GetIterator(); PrivateHashMap::Iterator it = fCookieHashMap->GetIterator();
while (it.HasNext()) { while (it.HasNext()) {
BNetworkCookieList* list = it.Next().value; BNetworkCookieList* list = it.Next().value;
it.Remove();
list->LockForWriting(); list->LockForWriting();
delete list; delete list;
} }
@@ -787,7 +786,7 @@ BNetworkCookieJar::UrlIterator::Remove()
fLastList->RemoveItemAt(fLastIndex); fLastList->RemoveItemAt(fLastIndex);
if (fLastList->CountItems() == 0) { if (fLastList->CountItems() == 0) {
fIterator->fCookieMapIterator.Remove(); fCookieJar->fCookieHashMap->Remove(fIterator->fCookieMapIterator);
delete fLastList; delete fLastList;
fLastList = NULL; fLastList = NULL;
} else { } else {