mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Bug #107369: Check nNewSize=0 in AllocateSpace() and add current size to AllocateSpace() calls. r=bienvenu,sr=sspitzer.
This commit is contained in:
parent
fa6a218016
commit
fc1fd71921
@ -166,9 +166,9 @@ nsresult nsMsgThreadedDBView::AddKeys(nsMsgKey *pKeys, PRInt32 *pFlags, const ch
|
||||
{
|
||||
PRInt32 numAdded = 0;
|
||||
// Allocate enough space first to avoid memory allocation/deallocation.
|
||||
m_keys.AllocateSpace(numKeysToAdd);
|
||||
m_flags.AllocateSpace(numKeysToAdd);
|
||||
m_levels.AllocateSpace(numKeysToAdd);
|
||||
m_keys.AllocateSpace(numKeysToAdd+m_keys.GetSize());
|
||||
m_flags.AllocateSpace(numKeysToAdd+m_flags.GetSize());
|
||||
m_levels.AllocateSpace(numKeysToAdd+m_levels.GetSize());
|
||||
for (PRInt32 i = 0; i < numKeysToAdd; i++)
|
||||
{
|
||||
PRInt32 threadFlag = pFlags[i];
|
||||
|
@ -44,6 +44,7 @@ public:
|
||||
PRUint32 GetSize() const;
|
||||
PRBool SetSize(PRUint32 nNewSize, PRBool AdjustGrowth=PR_FALSE, PRUint32 nGrowBy = 0);
|
||||
PRBool AllocateSpace(PRUint32 nNewSize) {
|
||||
if (nNewSize == 0) return PR_TRUE;
|
||||
PRUint32 saveSize = m_nSize;
|
||||
nsresult rv = SetSize(nNewSize);
|
||||
m_nSize = saveSize;
|
||||
|
@ -20,7 +20,7 @@ public:
|
||||
PRInt32 GetSize() const;
|
||||
PRInt32 GetUpperBound() const;
|
||||
void SetSize(PRInt32 nNewSize, PRInt32 nGrowBy = -1);
|
||||
void AllocateSpace(PRUint32 nNewSize) { PRInt32 saveSize = m_nSize; SetSize(nNewSize); m_nSize = saveSize;};
|
||||
void AllocateSpace(PRUint32 nNewSize) { if (nNewSize == 0) return; PRInt32 saveSize = m_nSize; SetSize(nNewSize); m_nSize = saveSize;};
|
||||
|
||||
// Operations
|
||||
// Clean up
|
||||
|
Loading…
Reference in New Issue
Block a user