mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 116957: Put Adopt on ns{C}String, and use it in nsStandardURL. r=dbaron, rs=scc
This commit is contained in:
parent
c8db620184
commit
75b1455d5d
@ -413,8 +413,7 @@ nsStandardURL::BuildNormalizedSpec(const char *spec)
|
||||
if (mDirectory.mLen > 1)
|
||||
CoalescePath(buf + mDirectory.mPos);
|
||||
|
||||
mSpec = buf; // XXX too bad there isn't some way of avoiding this strdup!
|
||||
free(buf);
|
||||
mSpec.Adopt(buf);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -864,7 +864,14 @@ void nsCString::InsertWithConversion(PRUnichar aChar,PRUint32 anOffset){
|
||||
}
|
||||
|
||||
|
||||
|
||||
void nsCString::Adopt(char* aPtr, PRInt32 aLength) {
|
||||
nsStr::Destroy(*this);
|
||||
if (aLength == -1)
|
||||
aLength = nsCharTraits<char>::length(aPtr);
|
||||
// We don't know the capacity, so we'll just have to assume
|
||||
// capacity = length.
|
||||
nsStr::Initialize(*this, aPtr, aLength, aLength, eOneByte, PR_TRUE);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
Searching methods...
|
||||
|
@ -301,6 +301,9 @@ public:
|
||||
#endif
|
||||
|
||||
|
||||
// Takes ownership of aPtr, sets the current length to aLength if specified.
|
||||
void Adopt( char* aPtr, PRInt32 aLength = -1 );
|
||||
|
||||
/**********************************************************************
|
||||
Searching methods...
|
||||
*********************************************************************/
|
||||
|
@ -866,6 +866,14 @@ void nsString::InsertWithConversion(const char* aCString,PRUint32 anOffset,PRInt
|
||||
}
|
||||
}
|
||||
|
||||
void nsString::Adopt(PRUnichar* aPtr, PRInt32 aLength) {
|
||||
nsStr::Destroy(*this);
|
||||
if (aLength == -1)
|
||||
aLength = nsCharTraits<PRUnichar>::length(aPtr);
|
||||
// We don't know the capacity, so we'll just have to assume
|
||||
// capacity = length.
|
||||
nsStr::Initialize(*this, (char*)aPtr, aLength, aLength, eTwoByte, PR_TRUE);
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
|
@ -322,6 +322,8 @@ public:
|
||||
//void InsertWithConversion(char);
|
||||
void InsertWithConversion(const char*, PRUint32, PRInt32=-1);
|
||||
|
||||
// Takes ownership of aPtr, sets the current length to aLength if specified.
|
||||
void Adopt( PRUnichar* aPtr, PRInt32 aLength = -1 );
|
||||
|
||||
/**********************************************************************
|
||||
Searching methods...
|
||||
|
@ -864,7 +864,14 @@ void nsCString::InsertWithConversion(PRUnichar aChar,PRUint32 anOffset){
|
||||
}
|
||||
|
||||
|
||||
|
||||
void nsCString::Adopt(char* aPtr, PRInt32 aLength) {
|
||||
nsStr::Destroy(*this);
|
||||
if (aLength == -1)
|
||||
aLength = nsCharTraits<char>::length(aPtr);
|
||||
// We don't know the capacity, so we'll just have to assume
|
||||
// capacity = length.
|
||||
nsStr::Initialize(*this, aPtr, aLength, aLength, eOneByte, PR_TRUE);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
Searching methods...
|
||||
|
@ -301,6 +301,9 @@ public:
|
||||
#endif
|
||||
|
||||
|
||||
// Takes ownership of aPtr, sets the current length to aLength if specified.
|
||||
void Adopt( char* aPtr, PRInt32 aLength = -1 );
|
||||
|
||||
/**********************************************************************
|
||||
Searching methods...
|
||||
*********************************************************************/
|
||||
|
@ -866,6 +866,14 @@ void nsString::InsertWithConversion(const char* aCString,PRUint32 anOffset,PRInt
|
||||
}
|
||||
}
|
||||
|
||||
void nsString::Adopt(PRUnichar* aPtr, PRInt32 aLength) {
|
||||
nsStr::Destroy(*this);
|
||||
if (aLength == -1)
|
||||
aLength = nsCharTraits<PRUnichar>::length(aPtr);
|
||||
// We don't know the capacity, so we'll just have to assume
|
||||
// capacity = length.
|
||||
nsStr::Initialize(*this, (char*)aPtr, aLength, aLength, eTwoByte, PR_TRUE);
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
|
@ -322,6 +322,8 @@ public:
|
||||
//void InsertWithConversion(char);
|
||||
void InsertWithConversion(const char*, PRUint32, PRInt32=-1);
|
||||
|
||||
// Takes ownership of aPtr, sets the current length to aLength if specified.
|
||||
void Adopt( PRUnichar* aPtr, PRInt32 aLength = -1 );
|
||||
|
||||
/**********************************************************************
|
||||
Searching methods...
|
||||
|
Loading…
Reference in New Issue
Block a user