Bug 671299 (part 2) - Add nsStringBuffer::SizeOfIncludingThisMustBeUnshared. r=bz.
This commit is contained in:
@@ -170,6 +170,12 @@ class nsStringBuffer
|
||||
void ToString(PRUint32 len, nsACString &str,
|
||||
bool aMoveOwnership = false);
|
||||
|
||||
/**
|
||||
* This measures the size. It should only be used if the StringBuffer is
|
||||
* unshared. This is checked.
|
||||
*/
|
||||
size_t SizeOfIncludingThisMustBeUnshared(nsMallocSizeOfFun aMallocSizeOf) const;
|
||||
|
||||
/**
|
||||
* This measures the size only if the StringBuffer is unshared.
|
||||
*/
|
||||
|
||||
@@ -307,12 +307,20 @@ nsStringBuffer::ToString(PRUint32 len, nsACString &str,
|
||||
accessor->set(data, len, flags);
|
||||
}
|
||||
|
||||
size_t
|
||||
nsStringBuffer::SizeOfIncludingThisMustBeUnshared(nsMallocSizeOfFun aMallocSizeOf) const
|
||||
{
|
||||
NS_ASSERTION(!IsReadonly(),
|
||||
"shared StringBuffer in SizeOfIncludingThisMustBeUnshared");
|
||||
return aMallocSizeOf(this);
|
||||
}
|
||||
|
||||
size_t
|
||||
nsStringBuffer::SizeOfIncludingThisIfUnshared(nsMallocSizeOfFun aMallocSizeOf) const
|
||||
{
|
||||
if (!IsReadonly())
|
||||
{
|
||||
return aMallocSizeOf(this);
|
||||
return SizeOfIncludingThisMustBeUnshared(aMallocSizeOf);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user