fixes for bugs #46898 and #46899: bad behavior in |nsCString::ToInteger| and a feature request for |ns[C]String::SetCapacity(0)| respectively. r={harishd, waterson}, a=waterson

git-svn-id: svn://10.0.0.236/trunk@75144 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
scc%mozilla.org
2000-07-29 03:11:59 +00:00
parent c222336587
commit 6ef6f1fd36
6 changed files with 117 additions and 78 deletions

View File

@@ -207,19 +207,26 @@ void nsString::SetLength(PRUint32 anIndex) {
/**
* Call this method if you want to force the string to a certain capacity
* @update gess 1/4/99
* @param aLength -- contains new length for mStr
* @return
* Call this method if you want to force the string to a certain capacity;
* |SetCapacity(0)| discards associated storage.
*
* @param aNewCapacity -- desired minimum capacity
*/
void nsString::SetCapacity(PRUint32 aLength) {
if(aLength) {
if(aLength>mCapacity) {
GrowCapacity(*this,aLength);
}
AddNullTerminator(*this);
void
nsString::SetCapacity( PRUint32 aNewCapacity )
{
if ( aNewCapacity )
{
if( aNewCapacity > mCapacity )
GrowCapacity(*this, aNewCapacity);
AddNullTerminator(*this);
}
else
{
nsStr::Destroy(*this);
nsStr::Initialize(*this, eTwoByte);
}
}
}
/**********************************************************************
Accessor methods...