зеркало из https://github.com/mozilla/pjs.git
bug 127941 Fixing leak of bucket memory; memset to 0 only if zeroit is
set. r=dougt, sr&a=shaver@mozilla.org
This commit is contained in:
Родитель
c019a232fd
Коммит
fe8cceb3a9
|
@ -122,6 +122,10 @@ nsRecyclingAllocator::~nsRecyclingAllocator()
|
|||
if (claimed && mMemBucket[i].ptr)
|
||||
free(mMemBucket[i].ptr);
|
||||
}
|
||||
|
||||
// Free memory for buckets
|
||||
if (mMemBucket)
|
||||
free(mMemBucket);
|
||||
}
|
||||
|
||||
// Allocation and free routines
|
||||
|
@ -159,6 +163,7 @@ nsRecyclingAllocator::Malloc(PRUint32 bytes, PRBool zeroit)
|
|||
// Let go of any freeAllocatedBucket that we claimed
|
||||
if (availableBucketIndex >= 0)
|
||||
Unclaim(availableBucketIndex);
|
||||
if (zeroit)
|
||||
memset(ptr, bytes, 0);
|
||||
return ptr;
|
||||
}
|
||||
|
@ -194,7 +199,21 @@ nsRecyclingAllocator::Malloc(PRUint32 bytes, PRBool zeroit)
|
|||
|
||||
// Take care of no memory and no free slot situation
|
||||
if (!ptr || mNAllocations == (PRInt32)mNBucket)
|
||||
{
|
||||
#ifdef DEBUG_dp
|
||||
// Warn if we are failing over to malloc and not storing it
|
||||
// This says we have a misdesigned memory pool. The intent was
|
||||
// once the pool was full, we would never fail over to calloc.
|
||||
printf("nsRecyclingAllocator(%s) malloc %d - FAILOVER 0x%p Memory pool has sizes: ",
|
||||
mId, bytes, ptr);
|
||||
for (i = 0; i < mNBucket; i++)
|
||||
{
|
||||
printf("%d ", mMemBucket[i].size);
|
||||
}
|
||||
printf("\n");
|
||||
#endif
|
||||
return ptr;
|
||||
}
|
||||
|
||||
// Find a free unallocated bucket and store allocation
|
||||
for (i = 0; i < mNBucket; i++)
|
||||
|
|
Загрузка…
Ссылка в новой задаче