Bug 1163331 - Update /mailnews/ for PLDHashTable API changes. r=rkent

This commit is contained in:
Nicholas Nethercote 2015-06-02 21:58:46 -07:00
Родитель 14dc230e89
Коммит c37604a68c
2 изменённых файлов: 10 добавлений и 15 удалений

Просмотреть файл

@ -488,7 +488,7 @@ nsresult nsMsgDatabase::AddHdrToCache(nsIMsgDBHdr *hdr, nsMsgKey key) // do we w
if (m_bCacheHeaders)
{
if (!m_cachedHeaders)
m_cachedHeaders = PL_NewDHashTable(&gMsgDBHashTableOps, sizeof(struct MsgHdrHashElement), m_cacheSize);
m_cachedHeaders = new PLDHashTable(&gMsgDBHashTableOps, sizeof(struct MsgHdrHashElement), m_cacheSize);
if (m_cachedHeaders)
{
if (key == nsMsgKey_None)
@ -665,15 +665,12 @@ nsresult nsMsgDatabase::ClearHdrCache(bool reInit)
if (reInit)
{
PL_DHashTableFinish(saveCachedHeaders);
PL_DHashTableInit(saveCachedHeaders, &gMsgDBHashTableOps,
sizeof(struct MsgHdrHashElement), m_cacheSize);
saveCachedHeaders->ClearAndPrepareForLength(m_cacheSize);
m_cachedHeaders = saveCachedHeaders;
}
else
{
PL_DHashTableDestroy(saveCachedHeaders);
delete saveCachedHeaders;
}
}
return NS_OK;
@ -775,7 +772,7 @@ nsresult nsMsgDatabase::AddHdrToUseCache(nsIMsgDBHdr *hdr, nsMsgKey key)
mdb_count numHdrs = MSG_HASH_SIZE;
if (m_mdbAllMsgHeadersTable)
m_mdbAllMsgHeadersTable->GetCount(GetEnv(), &numHdrs);
m_headersInUse = PL_NewDHashTable(&gMsgDBHashTableOps, sizeof(struct MsgHdrHashElement), std::max((mdb_count)MSG_HASH_SIZE, numHdrs));
m_headersInUse = new PLDHashTable(&gMsgDBHashTableOps, sizeof(struct MsgHdrHashElement), std::max((mdb_count)MSG_HASH_SIZE, numHdrs));
}
if (m_headersInUse)
{
@ -804,7 +801,7 @@ nsresult nsMsgDatabase::ClearUseHdrCache()
// clear mdb row pointers of any headers still in use, because the
// underlying db is going away.
PL_DHashTableEnumerate(m_headersInUse, ClearHeaderEnumerator, nullptr);
PL_DHashTableDestroy(m_headersInUse);
delete m_headersInUse;
m_headersInUse = nullptr;
}
return NS_OK;
@ -1148,7 +1145,7 @@ nsMsgDatabase::~nsMsgDatabase()
if (m_msgReferences)
{
PL_DHashTableDestroy(m_msgReferences);
delete m_msgReferences;
m_msgReferences = nullptr;
}
@ -4229,10 +4226,10 @@ nsresult nsMsgDatabase::InitRefHash()
{
// Delete an existing table just in case
if (m_msgReferences)
PL_DHashTableDestroy(m_msgReferences);
delete m_msgReferences;
// Create new table
m_msgReferences = PL_NewDHashTable(&gRefHashTableOps, sizeof(struct RefHashElement), MSG_HASH_SIZE);
m_msgReferences = new PLDHashTable(&gRefHashTableOps, sizeof(struct RefHashElement), MSG_HASH_SIZE);
if (!m_msgReferences)
return NS_ERROR_OUT_OF_MEMORY;

Просмотреть файл

@ -149,15 +149,14 @@ static const PLDHashTableOps gTokenTableOps = {
};
TokenHash::TokenHash(uint32_t aEntrySize)
: mTokenTable(&gTokenTableOps, aEntrySize, 128)
{
mEntrySize = aEntrySize;
PL_INIT_ARENA_POOL(&mWordPool, "Words Arena", 16384);
PL_DHashTableInit(&mTokenTable, &gTokenTableOps, aEntrySize, 128);
}
TokenHash::~TokenHash()
{
PL_DHashTableFinish(&mTokenTable);
PL_FinishArenaPool(&mWordPool);
}
@ -165,9 +164,8 @@ nsresult TokenHash::clearTokens()
{
// we re-use the tokenizer when classifying multiple messages,
// so this gets called after every message classification.
PL_DHashTableFinish(&mTokenTable);
mTokenTable.ClearAndPrepareForLength(128);
PL_FreeArenaPool(&mWordPool);
PL_DHashTableInit(&mTokenTable, &gTokenTableOps, mEntrySize, 128);
return NS_OK;
}