fix bloat when commiting dbs r=naving, sr=sspizer 76118

git-svn-id: svn://10.0.0.236/trunk@93232 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bienvenu%netscape.com 2001-04-27 04:03:12 +00:00
parent 3bd136c368
commit 3027538b8f
2 changed files with 1 additions and 58 deletions

View File

@ -31,7 +31,6 @@
#include "nsXPIDLString.h"
#include "nsMsgBaseCID.h"
#include "nsIArena.h"
static NS_DEFINE_CID(kMorkCID, NS_MORK_CID);
static NS_DEFINE_CID(kCMsgMailSessionCID, NS_MSGMAILSESSION_CID);
@ -39,26 +38,6 @@ static NS_DEFINE_CID(kCMsgMailSessionCID, NS_MSGMAILSESSION_CID);
const char *kFoldersScope = "ns:msg:db:row:scope:folders:all"; // scope for all folders table
const char *kFoldersTableKind = "ns:msg:db:table:kind:folders";
class FolderCachePool : public nsIMdbHeap { // caller-supplied memory management interface
public:
// { ===== begin nsIMdbHeap methods =====
virtual mdb_err Alloc(nsIMdbEnv* ev, // allocate a piece of memory
mdb_size inSize, // requested byte size of new memory block
void** outBlock); // memory block of inSize bytes, or nil
virtual mdb_err Free(nsIMdbEnv* ev, // free block from Alloc or Resize()
void* ioBlock); // block to be destroyed/deallocated
virtual mdb_err HeapAddStrongRef(nsIMdbEnv* ev);
virtual mdb_err HeapCutStrongRef(nsIMdbEnv* ev);
// } ===== end nsIMdbHeap methods =====
nsresult Init();
virtual ~FolderCachePool() {};
protected:
nsCOMPtr <nsIArena> m_arena;
};
nsMsgFolderCache::nsMsgFolderCache()
{
@ -66,9 +45,6 @@ nsMsgFolderCache::nsMsgFolderCache()
m_mdbStore = nsnull;
NS_INIT_REFCNT();
m_mdbAllFoldersTable = nsnull;
m_morkEnvMemPool = new FolderCachePool;
if (m_morkEnvMemPool)
m_morkEnvMemPool->Init();
}
// should this, could this be an nsCOMPtr ?
@ -90,7 +66,6 @@ nsMsgFolderCache::~nsMsgFolderCache()
m_mdbEnv->CloseMdbObject(m_mdbEnv);
// m_mdbEnv->CutStrongRef(m_mdbEnv); //??? is this right?
}
delete m_morkEnvMemPool;
}
@ -215,42 +190,13 @@ nsresult nsMsgFolderCache::InitExistingDB()
return err;
}
mdb_err FolderCachePool::Alloc(nsIMdbEnv* ev, // allocate a piece of memory
mdb_size inSize, // requested byte size of new memory block
void** outBlock)
{
*outBlock = m_arena->Alloc(inSize);
return (*outBlock) ? 0 : (mdb_err) -1;
}
mdb_err FolderCachePool::Free(nsIMdbEnv* ev, // free block from Alloc or Resize()
void* ioBlock) // block to be destroyed/deallocated
{
return 0;
}
mdb_err FolderCachePool::HeapAddStrongRef(nsIMdbEnv* ev)
{
return 0;
}
mdb_err FolderCachePool::HeapCutStrongRef(nsIMdbEnv* ev)
{
return 0;
}
nsresult FolderCachePool::Init()
{
return NS_NewHeapArena(getter_AddRefs(m_arena), 1024);
}
nsresult nsMsgFolderCache::OpenMDB(const char *dbName, PRBool exists)
{
nsresult ret=NS_OK;
nsIMdbFactory *myMDBFactory = GetMDBFactory();
if (myMDBFactory)
{
ret = myMDBFactory->MakeEnv(m_morkEnvMemPool, &m_mdbEnv);
ret = myMDBFactory->MakeEnv(nsnull, &m_mdbEnv);
if (NS_SUCCEEDED(ret))
{
nsIMdbThumb *thumb = nsnull;

View File

@ -30,8 +30,6 @@
#include "mdb.h"
#include "nsHashtable.h"
class FolderCachePool;
class nsMsgFolderCache : public nsIMsgFolderCache
{
@ -59,7 +57,6 @@ protected:
nsFileSpec m_dbFileSpec;
nsSupportsHashtable *m_cacheElements;
FolderCachePool *m_morkEnvMemPool;
// mdb stuff
nsIMdbEnv *m_mdbEnv; // to be used in all the db calls.
nsIMdbStore *m_mdbStore;