Bug 712835 (part 1 of 3) - Add nsStringBuffer::SizeOfIncludingThisIfUnshared(). r=khuey.

--HG--
extra : rebase_source : 44f4e4139aaefb003f95df0d9fbec7e1c06e7a9f
This commit is contained in:
Nicholas Nethercote 2011-12-22 16:57:30 -08:00
parent 3c44803f6b
commit 0d33b4e71c
2 changed files with 15 additions and 0 deletions

View File

@ -169,6 +169,11 @@ class nsStringBuffer
bool aMoveOwnership = false);
void ToString(PRUint32 len, nsACString &str,
bool aMoveOwnership = false);
/**
* This measures the size only if the StringBuffer is unshared.
*/
size_t SizeOfIncludingThisIfUnshared(nsMallocSizeOfFun aMallocSizeOf) const;
};
#endif /* !defined(nsStringBuffer_h__ */

View File

@ -307,6 +307,16 @@ nsStringBuffer::ToString(PRUint32 len, nsACString &str,
accessor->set(data, len, flags);
}
size_t
nsStringBuffer::SizeOfIncludingThisIfUnshared(nsMallocSizeOfFun aMallocSizeOf) const
{
if (!IsReadonly())
{
return aMallocSizeOf(this, sizeof(nsStringBuffer) + mStorageSize);
}
return 0;
}
// ---------------------------------------------------------------------------