Reworked sizeof api's to be much more useful; updated implementations to match

This commit is contained in:
kipp%netscape.com 1999-08-31 03:04:37 +00:00
Родитель 9cb1bab393
Коммит d07faca171
20 изменённых файлов: 332 добавлений и 150 удалений

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

@ -141,11 +141,10 @@ nsCString::~nsCString() {
nsStr::Destroy(*this,mAgent);
}
void nsCString::SizeOf(nsISizeOfHandler* aHandler) const {
#ifndef RICKG_TESTBED
aHandler->Add(sizeof(*this));
aHandler->Add(mCapacity << mCharSize);
#endif
void nsCString::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const {
if (aResult) {
*aResult = sizeof(*this) + mCapacity * mCharSize;
}
}
/**
@ -1848,11 +1847,10 @@ nsCAutoString::nsCAutoString( nsSubsumeCStr& aSubsumeStr) :nsCString() {
nsCAutoString::~nsCAutoString(){
}
void nsCAutoString::SizeOf(nsISizeOfHandler* aHandler) const {
#ifndef RICKG_TESTBED
aHandler->Add(sizeof(*this));
aHandler->Add(mCapacity << mCharSize);
#endif
void nsCAutoString::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const {
if (aResult) {
*aResult = sizeof(*this) + mCapacity * mCharSize;
}
}
nsSubsumeCStr::nsSubsumeCStr(nsStr& aString) : nsCString() {

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

@ -100,7 +100,7 @@ inline PRInt32 Length() const { return (PRInt32)mLength; }
* Retrieve the size of this string
* @return string length
*/
virtual void SizeOf(nsISizeOfHandler* aHandler) const;
virtual void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
/**
@ -715,7 +715,7 @@ public:
* Retrieve the size of this string
* @return string length
*/
virtual void SizeOf(nsISizeOfHandler* aHandler) const;
virtual void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
char mBuffer[kDefaultStringSize];
};

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

@ -120,11 +120,10 @@ nsString::~nsString() {
nsStr::Destroy(*this,mAgent);
}
void nsString::SizeOf(nsISizeOfHandler* aHandler) const {
#ifndef RICKG_TESTBED
aHandler->Add(sizeof(*this));
aHandler->Add(mCapacity << mCharSize);
#endif
void nsString::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const {
if (aResult) {
*aResult = sizeof(*this) + mCapacity * mCharSize;
}
}
/**
@ -2132,11 +2131,10 @@ nsAutoString::nsAutoString( nsSubsumeStr& aSubsumeStr) :nsString(aSubsumeStr.mCh
nsAutoString::~nsAutoString(){
}
void nsAutoString::SizeOf(nsISizeOfHandler* aHandler) const {
#ifndef RICKG_TESTBED
aHandler->Add(sizeof(*this));
aHandler->Add(mCapacity << mCharSize);
#endif
void nsAutoString::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const {
if (aResult) {
*aResult = sizeof(*this) + mCapacity * mCharSize;
}
}
nsSubsumeStr::nsSubsumeStr(nsStr& aString) : nsString(aString.mCharSize) {

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

@ -107,7 +107,7 @@ inline PRInt32 Length() const { return (PRInt32)mLength; }
* Retrieve the size of this string
* @return string length
*/
virtual void SizeOf(nsISizeOfHandler* aHandler) const;
virtual void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
/**
@ -799,7 +799,7 @@ public:
* Retrieve the size of this string
* @return string length
*/
virtual void SizeOf(nsISizeOfHandler* aHandler) const;
virtual void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
char mBuffer[kDefaultStringSize<<eTwoByte];
};

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

@ -78,9 +78,11 @@ AtomImpl::GetUnicode( PRUnichar** _retval ) /*FIX: const */
}
NS_IMETHODIMP
AtomImpl::SizeOf(nsISizeOfHandler* aHandler) /*FIX: const */
AtomImpl::SizeOf(nsISizeOfHandler* aHandler, PRUint32* _retval) /*FIX: const */
{
aHandler->Add(sizeof(*this) + nsCRT::strlen(mString) * sizeof(PRUnichar));
NS_ENSURE_ARG_POINTER(_retval);
PRUint32 sum = sizeof(*this) + nsCRT::strlen(mString) * sizeof(PRUnichar);
*_retval = sum;
return NS_OK;
}

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

@ -46,9 +46,9 @@ interface nsIAtom : nsISupports
wstring GetUnicode();
/**
* Add the size, in bytes, of the atom to the handler.
* Get the size, in bytes, of the atom.
*/
void SizeOf(in nsISizeOfHandler aHandler);
PRUint32 SizeOf(in nsISizeOfHandler aHandler);
};

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

@ -25,41 +25,73 @@
#define NS_ISIZEOF_HANDLER_IID \
{ 0xc028d1f0, 0xfc9e, 0x11d1, {0x89, 0xe4, 0x00, 0x60, 0x08, 0x91, 0x1b, 0x81}}
class nsIAtom;
class nsISizeOfHandler;
/**
* Function used by the Report method to report data gathered during
* a collection of data.
*/
typedef void (*nsISizeofReportFunc)(nsISizeOfHandler* aHandler,
nsIAtom* aKey,
PRUint32 aCount,
PRUint32 aTotalSize,
PRUint32 aMinSize,
PRUint32 aMaxSize,
void* aArg);
/**
* An API to managing a sizeof computation of an arbitrary graph.
* The handler is responsible for remembering which objects have been
* seen before. Note that the handler doesn't hold references to
* nsISupport's objects; the assumption is that the objects being
* sized are stationary and will not be modified during the sizing
* computation and therefore do not need an extra reference count.
* seen before (using RecordObject). Note that the handler doesn't
* hold references to nsISupport's objects; the assumption is that the
* objects being sized are stationary and will not be modified during
* the sizing computation and therefore do not need an extra reference
* count.
*
* Users of this API are responsible for the actual graph/tree walking.
*/
class nsISizeOfHandler : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISIZEOF_HANDLER_IID)
/**
* Add in a simple size value to the running total.
* Always returns NS_OK.
* Initialize the handler for a new collection of data. This empties
* out the object prescence table and the keyed size table.
*/
NS_IMETHOD Add(size_t aSize) = 0;
NS_IMETHOD Init() = 0;
/**
* Update aResult with PR_TRUE if the object has been traversed
* by the sizeof computation before. Otherwise aResult is set to
* PR_FALSE and the object is added to the internal database
* of objects that have been traversed. It's ok to pass a null
* pointer in; aResult will be set to PR_TRUE so you won't accidently
* try to traverse through null pointer.
*
* Note: This violates the COM API standard on purpose; so there!
* Record the sizing status of a given object. The first time
* aObject is recorded, aResult will be PR_FALSE. Subsequent times,
* aResult will be PR_TRUE.
*/
virtual PRBool HaveSeen(void* anObject) = 0;
NS_IMETHOD RecordObject(void* aObject, PRBool* aResult) = 0;
/**
* Return the currently computed size.
* Always returns NS_OK.
* Add size information to the running size data. The atom is used
* as a key to keep type specific running totals of size
* information. This increments the total count and the total size
* as well as updates the minimum, maximum and total size for aKey's
* type.
*/
NS_IMETHOD GetSize(PRUint32& aResult) = 0;
NS_IMETHOD AddSize(nsIAtom* aKey, PRUint32 aSize) = 0;
/**
* Enumerate data collected for each type and invoke the
* reporting function with the data gathered.
*/
NS_IMETHOD Report(nsISizeofReportFunc aFunc, void* aArg) = 0;
/**
* Get the current totals - the number of total objects sized (not
* necessarily anything to do with RecordObject's tracking of
* objects) and the total number of bytes that those object use. The
* counters are not reset by this call (use Init to reset
* everything).
*/
NS_IMETHOD GetTotals(PRUint32* aTotalCountResult,
PRUint32* aTotalSizeResult) = 0;
};
extern NS_COM nsresult

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

@ -16,6 +16,7 @@
* Reserved.
*/
#include "nsISizeOfHandler.h"
#include "nsIAtom.h"
#include "plhash.h"
class nsSizeOfHandler : public nsISizeOfHandler {
@ -27,90 +28,239 @@ public:
NS_DECL_ISUPPORTS
// nsISizeOfHandler
NS_IMETHOD Add(size_t aSize);
virtual PRBool HaveSeen(void* anObject);
NS_IMETHOD GetSize(PRUint32& aResult);
NS_IMETHOD Init();
NS_IMETHOD RecordObject(void* aObject, PRBool* aResult);
NS_IMETHOD AddSize(nsIAtom* aKey, PRUint32 aSize);
NS_IMETHOD Report(nsISizeofReportFunc aFunc, void* aArg);
NS_IMETHOD GetTotals(PRUint32* aCountResult, PRUint32* aTotalSizeResult);
protected:
PRUint32 mTotalSize;
PLHashTable* mTable;
PRUint32 mTotalCount;
PLHashTable* mSizeTable;
PLHashTable* mObjectTable;
static PRIntn RemoveObjectEntry(PLHashEntry* he, PRIntn i, void* arg);
static PRIntn RemoveSizeEntry(PLHashEntry* he, PRIntn i, void* arg);
static PRIntn ReportEntry(PLHashEntry* he, PRIntn i, void* arg);
};
static PLHashNumber
HashKey(void* key)
class SizeOfDataStats {
public:
SizeOfDataStats(nsIAtom* aType, PRUint32 aSize);
~SizeOfDataStats();
void Update(PRUint32 aSize);
nsIAtom* mType; // type
PRUint32 mCount; // # of objects of this type
PRUint32 mTotalSize; // total size of all objects of this type
PRUint32 mMinSize; // smallest size for this type
PRUint32 mMaxSize; // largest size for this type
};
//----------------------------------------------------------------------
SizeOfDataStats::SizeOfDataStats(nsIAtom* aType, PRUint32 aSize)
: mType(aType),
mCount(1),
mTotalSize(aSize),
mMinSize(aSize),
mMaxSize(aSize)
{
return (PLHashNumber) key;
NS_IF_ADDREF(mType);
}
SizeOfDataStats::~SizeOfDataStats()
{
NS_IF_RELEASE(mType);
}
void
SizeOfDataStats::Update(PRUint32 aSize)
{
mCount++;
if (aSize < mMinSize) mMinSize = aSize;
if (aSize > mMaxSize) mMaxSize = aSize;
mTotalSize += aSize;
}
//----------------------------------------------------------------------
#define POINTER_HASH_KEY(_atom) ((PLHashNumber) _atom)
static PLHashNumber
PointerHashKey(nsIAtom* key)
{
return POINTER_HASH_KEY(key);
}
static PRIntn
CompareKeys(void* key1, void* key2)
PointerCompareKeys(void* key1, void* key2)
{
return key1 == key2;
}
nsSizeOfHandler::nsSizeOfHandler()
: mTotalSize(0),
mTotalCount(0)
{
NS_INIT_REFCNT();
mTotalSize = 0;
mTable = PL_NewHashTable(8, (PLHashFunction) HashKey,
(PLHashComparator) CompareKeys,
(PLHashComparator) nsnull,
nsnull, nsnull);
mSizeTable = PL_NewHashTable(32, (PLHashFunction) PointerHashKey,
(PLHashComparator) PointerCompareKeys,
(PLHashComparator) nsnull,
nsnull, nsnull);
mObjectTable = PL_NewHashTable(32, (PLHashFunction) PointerHashKey,
(PLHashComparator) PointerCompareKeys,
(PLHashComparator) nsnull,
nsnull, nsnull);
}
PRIntn
nsSizeOfHandler::RemoveObjectEntry(PLHashEntry* he, PRIntn i, void* arg)
{
// Remove and free this entry and continue enumerating
return HT_ENUMERATE_REMOVE | HT_ENUMERATE_NEXT;
}
PRIntn
nsSizeOfHandler::RemoveSizeEntry(PLHashEntry* he, PRIntn i, void* arg)
{
if (he->value) {
SizeOfDataStats* stats = (SizeOfDataStats*) he->value;
he->value = nsnull;
delete stats;
}
// Remove and free this entry and continue enumerating
return HT_ENUMERATE_REMOVE | HT_ENUMERATE_NEXT;
}
nsSizeOfHandler::~nsSizeOfHandler()
{
if (nsnull != mTable) {
PL_HashTableDestroy(mTable);
if (nsnull != mObjectTable) {
PL_HashTableEnumerateEntries(mObjectTable, RemoveObjectEntry, 0);
PL_HashTableDestroy(mObjectTable);
}
if (nsnull != mSizeTable) {
PL_HashTableEnumerateEntries(mSizeTable, RemoveSizeEntry, 0);
PL_HashTableDestroy(mSizeTable);
}
}
NS_IMPL_ISUPPORTS1(nsSizeOfHandler, nsISizeOfHandler)
NS_IMETHODIMP
nsSizeOfHandler::Add(size_t aSize)
nsSizeOfHandler::Init()
{
if (mObjectTable) {
PL_HashTableEnumerateEntries(mObjectTable, RemoveObjectEntry, 0);
}
if (mSizeTable) {
PL_HashTableEnumerateEntries(mSizeTable, RemoveSizeEntry, 0);
}
mTotalCount = 0;
mTotalSize = 0;
return NS_OK;
}
NS_IMETHODIMP
nsSizeOfHandler::RecordObject(void* aAddr, PRBool* aResult)
{
if (!aResult) {
return NS_ERROR_NULL_POINTER;
}
PRBool result = PR_TRUE;
if (mObjectTable && aAddr) {
PLHashNumber hashCode = POINTER_HASH_KEY(aAddr);
PLHashEntry** hep = PL_HashTableRawLookup(mObjectTable, hashCode, aAddr);
PLHashEntry* he = *hep;
if (!he) {
// We've never seen it before. Add it to the table
(void) PL_HashTableRawAdd(mObjectTable, hep, hashCode, aAddr, aAddr);
result = PR_FALSE;
}
}
*aResult = result;
return NS_OK;
}
NS_IMETHODIMP
nsSizeOfHandler::AddSize(nsIAtom* aType, PRUint32 aSize)
{
PLHashNumber hashCode = POINTER_HASH_KEY(aType);
PLHashEntry** hep = PL_HashTableRawLookup(mSizeTable, hashCode, aType);
PLHashEntry* he = *hep;
if (he) {
// Stats already exist
SizeOfDataStats* stats = (SizeOfDataStats*) he->value;
stats->Update(aSize);
}
else {
// Make new stats for the new frame type
SizeOfDataStats* newStats = new SizeOfDataStats(aType, aSize);
PL_HashTableRawAdd(mSizeTable, hep, hashCode, aType, newStats);
}
mTotalCount++;
mTotalSize += aSize;
return NS_OK;
}
PRBool
nsSizeOfHandler::HaveSeen(void* anObject)
struct ReportArgs {
nsISizeOfHandler* mHandler;
nsISizeofReportFunc mFunc;
void* mArg;
};
PRIntn
nsSizeOfHandler::ReportEntry(PLHashEntry* he, PRIntn i, void* arg)
{
if (nsnull == mTable) {
// When we run out of memory, HaveSeen returns PR_TRUE to stop
// wasting time.
return PR_TRUE;
ReportArgs* ra = (ReportArgs*) arg;
if (he && ra && ra->mFunc) {
SizeOfDataStats* stats = (SizeOfDataStats*) he->value;
if (stats) {
(*ra->mFunc)(ra->mHandler, stats->mType, stats->mCount,
stats->mTotalSize, stats->mMinSize, stats->mMaxSize,
ra->mArg);
}
}
if (nsnull != anObject) {
PRInt32 hashCode = (PRInt32) anObject;
PLHashEntry** hep = PL_HashTableRawLookup(mTable, hashCode, anObject);
PLHashEntry* he = *hep;
if (nsnull != he) {
return PR_TRUE;
}
he = PL_HashTableRawAdd(mTable, hep, hashCode, anObject, anObject);
if (nsnull == he) {
// When we run out of memory, HaveSeen returns PR_TRUE to stop
// wasting time.
return PR_TRUE;
}
return PR_FALSE;
}
return PR_TRUE;
// Remove and free this entry and continue enumerating
return HT_ENUMERATE_REMOVE | HT_ENUMERATE_NEXT;
}
NS_IMETHODIMP
nsSizeOfHandler::GetSize(PRUint32& aResult)
nsSizeOfHandler::Report(nsISizeofReportFunc aFunc, void* aArg)
{
aResult = mTotalSize;
ReportArgs ra;
ra.mHandler = this;
ra.mFunc = aFunc;
ra.mArg = aArg;
PL_HashTableEnumerateEntries(mSizeTable, ReportEntry, (void*) &ra);
return NS_OK;
}
NS_IMETHODIMP
nsSizeOfHandler::GetTotals(PRUint32* aTotalCountResult,
PRUint32* aTotalSizeResult)
{
if (!aTotalCountResult || !aTotalSizeResult) {
return NS_ERROR_NULL_POINTER;
}
*aTotalCountResult = mTotalCount;
*aTotalSizeResult = mTotalSize;
return NS_OK;
}
NS_COM nsresult
NS_NewSizeOfHandler(nsISizeOfHandler** aInstancePtrResult)
{
if (!aInstancePtrResult) {
return NS_ERROR_NULL_POINTER;
}
nsISizeOfHandler *it = new nsSizeOfHandler();
if (it == nsnull) {
return NS_ERROR_OUT_OF_MEMORY;

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

@ -141,11 +141,10 @@ nsCString::~nsCString() {
nsStr::Destroy(*this,mAgent);
}
void nsCString::SizeOf(nsISizeOfHandler* aHandler) const {
#ifndef RICKG_TESTBED
aHandler->Add(sizeof(*this));
aHandler->Add(mCapacity << mCharSize);
#endif
void nsCString::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const {
if (aResult) {
*aResult = sizeof(*this) + mCapacity * mCharSize;
}
}
/**
@ -1848,11 +1847,10 @@ nsCAutoString::nsCAutoString( nsSubsumeCStr& aSubsumeStr) :nsCString() {
nsCAutoString::~nsCAutoString(){
}
void nsCAutoString::SizeOf(nsISizeOfHandler* aHandler) const {
#ifndef RICKG_TESTBED
aHandler->Add(sizeof(*this));
aHandler->Add(mCapacity << mCharSize);
#endif
void nsCAutoString::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const {
if (aResult) {
*aResult = sizeof(*this) + mCapacity * mCharSize;
}
}
nsSubsumeCStr::nsSubsumeCStr(nsStr& aString) : nsCString() {

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

@ -100,7 +100,7 @@ inline PRInt32 Length() const { return (PRInt32)mLength; }
* Retrieve the size of this string
* @return string length
*/
virtual void SizeOf(nsISizeOfHandler* aHandler) const;
virtual void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
/**
@ -715,7 +715,7 @@ public:
* Retrieve the size of this string
* @return string length
*/
virtual void SizeOf(nsISizeOfHandler* aHandler) const;
virtual void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
char mBuffer[kDefaultStringSize];
};

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

@ -120,11 +120,10 @@ nsString::~nsString() {
nsStr::Destroy(*this,mAgent);
}
void nsString::SizeOf(nsISizeOfHandler* aHandler) const {
#ifndef RICKG_TESTBED
aHandler->Add(sizeof(*this));
aHandler->Add(mCapacity << mCharSize);
#endif
void nsString::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const {
if (aResult) {
*aResult = sizeof(*this) + mCapacity * mCharSize;
}
}
/**
@ -2132,11 +2131,10 @@ nsAutoString::nsAutoString( nsSubsumeStr& aSubsumeStr) :nsString(aSubsumeStr.mCh
nsAutoString::~nsAutoString(){
}
void nsAutoString::SizeOf(nsISizeOfHandler* aHandler) const {
#ifndef RICKG_TESTBED
aHandler->Add(sizeof(*this));
aHandler->Add(mCapacity << mCharSize);
#endif
void nsAutoString::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const {
if (aResult) {
*aResult = sizeof(*this) + mCapacity * mCharSize;
}
}
nsSubsumeStr::nsSubsumeStr(nsStr& aString) : nsString(aString.mCharSize) {

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

@ -107,7 +107,7 @@ inline PRInt32 Length() const { return (PRInt32)mLength; }
* Retrieve the size of this string
* @return string length
*/
virtual void SizeOf(nsISizeOfHandler* aHandler) const;
virtual void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
/**
@ -799,7 +799,7 @@ public:
* Retrieve the size of this string
* @return string length
*/
virtual void SizeOf(nsISizeOfHandler* aHandler) const;
virtual void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
char mBuffer[kDefaultStringSize<<eTwoByte];
};

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

@ -60,11 +60,13 @@ nsVoidArray::~nsVoidArray()
delete [] mArray;
}
}
void
nsVoidArray::SizeOf(nsISizeOfHandler* aHandler) const
nsVoidArray::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const
{
aHandler->Add(sizeof(*this));
aHandler->Add(sizeof(void*) * mArraySize);
if (aResult) {
*aResult = sizeof(*this) + sizeof(void*) * mArraySize;
}
}
void* nsVoidArray::ElementAt(PRInt32 aIndex) const
@ -261,13 +263,16 @@ nsStringArray::operator=(const nsStringArray& other)
}
void
nsStringArray::SizeOf(nsISizeOfHandler* aHandler) const
nsStringArray::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const
{
nsVoidArray::SizeOf(aHandler);
PRUint32 sum = 0;
nsVoidArray::SizeOf(aHandler, &sum);
PRInt32 index = mCount;
while (0 <= --index) {
nsString* string = (nsString*)mArray[index];
string->SizeOf(aHandler);
PRUint32 size;
string->SizeOf(aHandler, &size);
sum += size;
}
}

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

@ -33,7 +33,7 @@ public:
nsVoidArray& operator=(const nsVoidArray& other);
void SizeOf(nsISizeOfHandler* aHandler) const;
void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
PRInt32 Count() const {
return mCount;
@ -84,7 +84,7 @@ public:
nsStringArray& operator=(const nsStringArray& other);
void SizeOf(nsISizeOfHandler* aHandler) const;
void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
PRInt32 Count(void) const {
return mCount;

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

@ -60,11 +60,13 @@ nsVoidArray::~nsVoidArray()
delete [] mArray;
}
}
void
nsVoidArray::SizeOf(nsISizeOfHandler* aHandler) const
nsVoidArray::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const
{
aHandler->Add(sizeof(*this));
aHandler->Add(sizeof(void*) * mArraySize);
if (aResult) {
*aResult = sizeof(*this) + sizeof(void*) * mArraySize;
}
}
void* nsVoidArray::ElementAt(PRInt32 aIndex) const
@ -261,13 +263,16 @@ nsStringArray::operator=(const nsStringArray& other)
}
void
nsStringArray::SizeOf(nsISizeOfHandler* aHandler) const
nsStringArray::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const
{
nsVoidArray::SizeOf(aHandler);
PRUint32 sum = 0;
nsVoidArray::SizeOf(aHandler, &sum);
PRInt32 index = mCount;
while (0 <= --index) {
nsString* string = (nsString*)mArray[index];
string->SizeOf(aHandler);
PRUint32 size;
string->SizeOf(aHandler, &size);
sum += size;
}
}

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

@ -33,7 +33,7 @@ public:
nsVoidArray& operator=(const nsVoidArray& other);
void SizeOf(nsISizeOfHandler* aHandler) const;
void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
PRInt32 Count() const {
return mCount;
@ -84,7 +84,7 @@ public:
nsStringArray& operator=(const nsStringArray& other);
void SizeOf(nsISizeOfHandler* aHandler) const;
void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
PRInt32 Count(void) const {
return mCount;

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

@ -141,11 +141,10 @@ nsCString::~nsCString() {
nsStr::Destroy(*this,mAgent);
}
void nsCString::SizeOf(nsISizeOfHandler* aHandler) const {
#ifndef RICKG_TESTBED
aHandler->Add(sizeof(*this));
aHandler->Add(mCapacity << mCharSize);
#endif
void nsCString::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const {
if (aResult) {
*aResult = sizeof(*this) + mCapacity * mCharSize;
}
}
/**
@ -1848,11 +1847,10 @@ nsCAutoString::nsCAutoString( nsSubsumeCStr& aSubsumeStr) :nsCString() {
nsCAutoString::~nsCAutoString(){
}
void nsCAutoString::SizeOf(nsISizeOfHandler* aHandler) const {
#ifndef RICKG_TESTBED
aHandler->Add(sizeof(*this));
aHandler->Add(mCapacity << mCharSize);
#endif
void nsCAutoString::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const {
if (aResult) {
*aResult = sizeof(*this) + mCapacity * mCharSize;
}
}
nsSubsumeCStr::nsSubsumeCStr(nsStr& aString) : nsCString() {

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

@ -100,7 +100,7 @@ inline PRInt32 Length() const { return (PRInt32)mLength; }
* Retrieve the size of this string
* @return string length
*/
virtual void SizeOf(nsISizeOfHandler* aHandler) const;
virtual void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
/**
@ -715,7 +715,7 @@ public:
* Retrieve the size of this string
* @return string length
*/
virtual void SizeOf(nsISizeOfHandler* aHandler) const;
virtual void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
char mBuffer[kDefaultStringSize];
};

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

@ -120,11 +120,10 @@ nsString::~nsString() {
nsStr::Destroy(*this,mAgent);
}
void nsString::SizeOf(nsISizeOfHandler* aHandler) const {
#ifndef RICKG_TESTBED
aHandler->Add(sizeof(*this));
aHandler->Add(mCapacity << mCharSize);
#endif
void nsString::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const {
if (aResult) {
*aResult = sizeof(*this) + mCapacity * mCharSize;
}
}
/**
@ -2132,11 +2131,10 @@ nsAutoString::nsAutoString( nsSubsumeStr& aSubsumeStr) :nsString(aSubsumeStr.mCh
nsAutoString::~nsAutoString(){
}
void nsAutoString::SizeOf(nsISizeOfHandler* aHandler) const {
#ifndef RICKG_TESTBED
aHandler->Add(sizeof(*this));
aHandler->Add(mCapacity << mCharSize);
#endif
void nsAutoString::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const {
if (aResult) {
*aResult = sizeof(*this) + mCapacity * mCharSize;
}
}
nsSubsumeStr::nsSubsumeStr(nsStr& aString) : nsString(aString.mCharSize) {

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

@ -107,7 +107,7 @@ inline PRInt32 Length() const { return (PRInt32)mLength; }
* Retrieve the size of this string
* @return string length
*/
virtual void SizeOf(nsISizeOfHandler* aHandler) const;
virtual void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
/**
@ -799,7 +799,7 @@ public:
* Retrieve the size of this string
* @return string length
*/
virtual void SizeOf(nsISizeOfHandler* aHandler) const;
virtual void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
char mBuffer[kDefaultStringSize<<eTwoByte];
};