зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1386103 (part 2, attempt 3) - Convert nsFixed[C]String uses to nsAuto[C]String. r=erahm.
This commit is contained in:
Родитель
65b902e3ea
Коммит
dc5e4a62cf
|
@ -19,12 +19,10 @@
|
|||
//// NullPrincipalURI
|
||||
|
||||
NullPrincipalURI::NullPrincipalURI()
|
||||
: mPath(mPathBytes, ArrayLength(mPathBytes), ArrayLength(mPathBytes) - 1)
|
||||
{
|
||||
}
|
||||
|
||||
NullPrincipalURI::NullPrincipalURI(const NullPrincipalURI& aOther)
|
||||
: mPath(mPathBytes, ArrayLength(mPathBytes), ArrayLength(mPathBytes) - 1)
|
||||
{
|
||||
mPath.Assign(aOther.mPath);
|
||||
}
|
||||
|
@ -40,9 +38,9 @@ NullPrincipalURI::Init()
|
|||
nsresult rv = uuidgen->GenerateUUIDInPlace(&id);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
MOZ_ASSERT(mPathBytes == mPath.BeginWriting());
|
||||
|
||||
id.ToProvidedString(mPathBytes);
|
||||
mPath.SetLength(NSID_LENGTH - 1); // -1 because NSID_LENGTH counts the '\0'
|
||||
id.ToProvidedString(
|
||||
*reinterpret_cast<char(*)[NSID_LENGTH]>(mPath.BeginWriting()));
|
||||
|
||||
MOZ_ASSERT(mPath.Length() == NSID_LENGTH - 1);
|
||||
MOZ_ASSERT(strlen(mPath.get()) == NSID_LENGTH - 1);
|
||||
|
|
|
@ -52,8 +52,7 @@ private:
|
|||
|
||||
nsresult Init();
|
||||
|
||||
char mPathBytes[NSID_LENGTH];
|
||||
nsFixedCString mPath;
|
||||
nsAutoCStringN<NSID_LENGTH> mPath;
|
||||
};
|
||||
|
||||
#endif // __NullPrincipalURI_h__
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace dom {
|
|||
namespace indexedDB {
|
||||
|
||||
class MOZ_STACK_CLASS LoggingIdString final
|
||||
: public nsAutoCString
|
||||
: public nsAutoCStringN<NSID_LENGTH>
|
||||
{
|
||||
public:
|
||||
LoggingIdString()
|
||||
|
@ -62,8 +62,9 @@ public:
|
|||
{
|
||||
static_assert(NSID_LENGTH > 1, "NSID_LENGTH is set incorrectly!");
|
||||
static_assert(NSID_LENGTH <= kStorageSize,
|
||||
"nID string won't fit in our storage!");
|
||||
MOZ_ASSERT(Capacity() > NSID_LENGTH);
|
||||
"nsID string won't fit in our storage!");
|
||||
// Capacity() excludes the null terminator; NSID_LENGTH includes it.
|
||||
MOZ_ASSERT(Capacity() + 1 == NSID_LENGTH);
|
||||
|
||||
if (IndexedDatabaseManager::GetLoggingMode() !=
|
||||
IndexedDatabaseManager::Logging_Disabled) {
|
||||
|
|
|
@ -1993,12 +1993,9 @@ ContentParent::LaunchSubprocess(ProcessPriority aInitialPriority /* = PROCESS_PR
|
|||
extraArgs.push_back(idStr);
|
||||
extraArgs.push_back(IsForBrowser() ? "-isForBrowser" : "-notForBrowser");
|
||||
|
||||
char boolBuf[1024];
|
||||
char intBuf[1024];
|
||||
char strBuf[1024];
|
||||
nsFixedCString boolPrefs(boolBuf, 1024, 0);
|
||||
nsFixedCString intPrefs(intBuf, 1024, 0);
|
||||
nsFixedCString stringPrefs(strBuf, 1024, 0);
|
||||
nsAutoCStringN<1024> boolPrefs;
|
||||
nsAutoCStringN<1024> intPrefs;
|
||||
nsAutoCStringN<1024> stringPrefs;
|
||||
|
||||
size_t prefsLen;
|
||||
ContentPrefs::GetContentPrefs(&prefsLen);
|
||||
|
|
|
@ -600,8 +600,7 @@ nsXULContentBuilder::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
|||
// given node.
|
||||
// SynchronizeUsingTemplate contains code used to update textnodes,
|
||||
// so make sure to modify both when changing this
|
||||
char16_t attrbuf[128];
|
||||
nsFixedString attrValue(attrbuf, ArrayLength(attrbuf), 0);
|
||||
nsAutoString attrValue;
|
||||
tmplKid->GetAttr(kNameSpaceID_None, nsGkAtoms::value, attrValue);
|
||||
if (!attrValue.IsEmpty()) {
|
||||
nsAutoString value;
|
||||
|
@ -737,11 +736,7 @@ nsXULContentBuilder::CopyAttributesToElement(nsIContent* aTemplateNode,
|
|||
|
||||
// XXXndeakin ignore namespaces until bug 321182 is fixed
|
||||
if (attribName != nsGkAtoms::id && attribName != nsGkAtoms::uri) {
|
||||
// Create a buffer here, because there's a chance that an
|
||||
// attribute in the template is going to be an RDF URI, which is
|
||||
// usually longish.
|
||||
char16_t attrbuf[128];
|
||||
nsFixedString attribValue(attrbuf, ArrayLength(attrbuf), 0);
|
||||
nsAutoString attribValue;
|
||||
aTemplateNode->GetAttr(attribNameSpaceID, attribName, attribValue);
|
||||
if (!attribValue.IsEmpty()) {
|
||||
nsAutoString value;
|
||||
|
@ -878,8 +873,7 @@ nsXULContentBuilder::SynchronizeUsingTemplate(nsIContent* aTemplateNode,
|
|||
// This code is similar to that in BuildContentFromTemplate
|
||||
if (tmplKid->NodeInfo()->Equals(nsGkAtoms::textnode,
|
||||
kNameSpaceID_XUL)) {
|
||||
char16_t attrbuf[128];
|
||||
nsFixedString attrValue(attrbuf, ArrayLength(attrbuf), 0);
|
||||
nsAutoString attrValue;
|
||||
tmplKid->GetAttr(kNameSpaceID_None, nsGkAtoms::value, attrValue);
|
||||
if (!attrValue.IsEmpty()) {
|
||||
nsAutoString value;
|
||||
|
|
|
@ -255,8 +255,7 @@ nsXULContentUtils::GetResource(int32_t aNameSpaceID, const nsAString& aAttribute
|
|||
|
||||
nsresult rv;
|
||||
|
||||
char16_t buf[256];
|
||||
nsFixedString uri(buf, ArrayLength(buf), 0);
|
||||
nsAutoStringN<256> uri;
|
||||
if (aNameSpaceID != kNameSpaceID_Unknown && aNameSpaceID != kNameSpaceID_None) {
|
||||
rv = nsContentUtils::NameSpaceManager()->GetNameSpaceURI(aNameSpaceID, uri);
|
||||
// XXX ignore failure; treat as "no namespace"
|
||||
|
|
|
@ -687,8 +687,7 @@ RDFContainerImpl::GetNextValue(nsIRDFResource** aResult)
|
|||
}
|
||||
|
||||
static const char kRDFNameSpaceURI[] = RDF_NAMESPACE_URI;
|
||||
char buf[sizeof(kRDFNameSpaceURI) + 16];
|
||||
nsFixedCString nextValStr(buf, sizeof(buf), 0);
|
||||
nsAutoCStringN<sizeof(kRDFNameSpaceURI) + 16> nextValStr;
|
||||
nextValStr = kRDFNameSpaceURI;
|
||||
nextValStr.Append('_');
|
||||
nextValStr.AppendInt(nextVal, 10);
|
||||
|
|
|
@ -20,23 +20,18 @@
|
|||
*
|
||||
* See also nsCString::AppendPrintf().
|
||||
*/
|
||||
class nsPrintfCString : public nsFixedCString
|
||||
class nsPrintfCString : public nsAutoCStringN<16>
|
||||
{
|
||||
typedef nsCString string_type;
|
||||
|
||||
public:
|
||||
explicit nsPrintfCString(const char_type* aFormat, ...) MOZ_FORMAT_PRINTF(2, 3)
|
||||
: nsFixedCString(mLocalBuffer, kLocalBufferSize, 0)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, aFormat);
|
||||
AppendPrintf(aFormat, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
private:
|
||||
static const uint32_t kLocalBufferSize = 16;
|
||||
char_type mLocalBuffer[kLocalBufferSize];
|
||||
};
|
||||
|
||||
#endif // !defined(nsPrintfCString_h___)
|
||||
|
|
Загрузка…
Ссылка в новой задаче