diff --git a/mozilla/browser/components/migration/src/nsSafariProfileMigrator.cpp b/mozilla/browser/components/migration/src/nsSafariProfileMigrator.cpp index 935745e1894..909bb817edd 100644 --- a/mozilla/browser/components/migration/src/nsSafariProfileMigrator.cpp +++ b/mozilla/browser/components/migration/src/nsSafariProfileMigrator.cpp @@ -64,7 +64,7 @@ #include "nsSafariProfileMigrator.h" #include "nsToolkitCompsCID.h" #include "nsNetUtil.h" -#include "nsAutoBuffer.h" +#include "nsTArray.h" #include @@ -311,12 +311,12 @@ GetDictionaryStringValue(CFDictionaryRef aDictionary, CFStringRef aKey, { CFStringRef value = (CFStringRef)::CFDictionaryGetValue(aDictionary, aKey); if (value) { - nsAutoBuffer buffer; + nsAutoTArray buffer; CFIndex valueLength = ::CFStringGetLength(value); - buffer.EnsureElemCapacity(valueLength); + buffer.SetLength(valueLength); - ::CFStringGetCharacters(value, CFRangeMake(0, valueLength), buffer.get()); - aResult.Assign(buffer.get(), valueLength); + ::CFStringGetCharacters(value, CFRangeMake(0, valueLength), buffer.Elements()); + aResult.Assign(buffer.Elements(), valueLength); return PR_TRUE; } return PR_FALSE; @@ -328,12 +328,12 @@ GetDictionaryCStringValue(CFDictionaryRef aDictionary, CFStringRef aKey, { CFStringRef value = (CFStringRef)::CFDictionaryGetValue(aDictionary, aKey); if (value) { - nsAutoBuffer buffer; + nsAutoTArray buffer; CFIndex valueLength = ::CFStringGetLength(value); - buffer.EnsureElemCapacity(valueLength + 1); + buffer.SetLength(valueLength + 1); - if (::CFStringGetCString(value, buffer.get(), valueLength + 1, aEncoding)) { - aResult = buffer.get(); + if (::CFStringGetCString(value, buffer.Elements(), valueLength + 1, aEncoding)) { + aResult = buffer.Elements(); return PR_TRUE; } } @@ -345,12 +345,12 @@ GetArrayStringValue(CFArrayRef aArray, PRInt32 aIndex, nsAString& aResult) { CFStringRef value = (CFStringRef)::CFArrayGetValueAtIndex(aArray, aIndex); if (value) { - nsAutoBuffer buffer; + nsAutoTArray buffer; CFIndex valueLength = ::CFStringGetLength(value); - buffer.EnsureElemCapacity(valueLength); + buffer.SetLength(valueLength); - ::CFStringGetCharacters(value, CFRangeMake(0, valueLength), buffer.get()); - aResult.Assign(buffer.get(), valueLength); + ::CFStringGetCharacters(value, CFRangeMake(0, valueLength), buffer.Elements()); + aResult.Assign(buffer.Elements(), valueLength); return PR_TRUE; } return PR_FALSE; diff --git a/mozilla/embedding/components/printingui/src/mac/nsPrintingPromptServiceX.cpp b/mozilla/embedding/components/printingui/src/mac/nsPrintingPromptServiceX.cpp index 039a9d4d79c..f65b9466db6 100644 --- a/mozilla/embedding/components/printingui/src/mac/nsPrintingPromptServiceX.cpp +++ b/mozilla/embedding/components/printingui/src/mac/nsPrintingPromptServiceX.cpp @@ -52,7 +52,7 @@ #include "nsIPrintSettingsX.h" #include "nsIDirectoryService.h" #include "nsDirectoryServiceDefs.h" -#include "nsAutoBuffer.h" +#include "nsTArray.h" #include "nsPDECommon.h" @@ -98,11 +98,11 @@ static CFDictionaryRef ExtractCustomSettingsDict(PMPrintSettings nativePrintSett OSStatus status = ::PMGetPrintSettingsExtendedData(nativePrintSettings, kAppPrintDialogAppOnlyKey, &bytesNeeded, NULL); if (status == noErr) { - nsAutoBuffer dataBuffer; - if (dataBuffer.EnsureElemCapacity(bytesNeeded)) { - status = ::PMGetPrintSettingsExtendedData(nativePrintSettings, kAppPrintDialogAppOnlyKey, &bytesNeeded, dataBuffer.get()); + nsAutoTArray dataBuffer; + if (dataBuffer.SetLength(bytesNeeded)) { + status = ::PMGetPrintSettingsExtendedData(nativePrintSettings, kAppPrintDialogAppOnlyKey, &bytesNeeded, dataBuffer.Elements()); if (status == noErr) { - CFDataRef xmlData = ::CFDataCreate(kCFAllocatorDefault, dataBuffer.get(), bytesNeeded); + CFDataRef xmlData = ::CFDataCreate(kCFAllocatorDefault, dataBuffer.Elements(), bytesNeeded); if (xmlData) { resultDict = (CFDictionaryRef)::CFPropertyListCreateFromXMLData( kCFAllocatorDefault, @@ -128,10 +128,10 @@ GetDictionaryStringValue(CFDictionaryRef aDictionary, CFStringRef aKey, nsAStrin { CFIndex stringLen = CFStringGetLength((CFStringRef)dictValue); - nsAutoBuffer stringBuffer; - if (stringBuffer.EnsureElemCapacity(stringLen + 1)) { - ::CFStringGetCharacters((CFStringRef)dictValue, CFRangeMake(0, stringLen), stringBuffer.get()); - aResult.Assign(stringBuffer.get(), stringLen); + nsAutoTArray stringBuffer; + if (stringBuffer.SetLength(stringLen + 1)) { + ::CFStringGetCharacters((CFStringRef)dictValue, CFRangeMake(0, stringLen), stringBuffer.Elements()); + aResult.Assign(stringBuffer.Elements(), stringLen); return PR_TRUE; } } diff --git a/mozilla/extensions/xforms/nsXFormsUploadElement.cpp b/mozilla/extensions/xforms/nsXFormsUploadElement.cpp index a1231ba49f9..9b392bcb8d1 100644 --- a/mozilla/extensions/xforms/nsXFormsUploadElement.cpp +++ b/mozilla/extensions/xforms/nsXFormsUploadElement.cpp @@ -52,7 +52,7 @@ #include "nsIDOMWindowInternal.h" #include "nsIAttribute.h" #include "nsIStringBundle.h" -#include "nsAutoBuffer.h" +#include "nsTArray.h" #include "nsIEventStateManager.h" #include "prmem.h" #include "nsISchema.h" @@ -442,7 +442,7 @@ nsXFormsUploadElement::HandleChildElements(nsILocalFile *aFile, return rv; } -typedef nsAutoBuffer nsAutoCharBuffer; +typedef nsAutoTArray nsAutoCharBuffer; static void ReportEncodingMemoryError(nsIDOMElement* aElement, nsIFile *aFile, @@ -478,13 +478,13 @@ nsXFormsUploadElement::EncodeFileContents(nsIFile *aFile, PRUint16 aType, NS_ENSURE_SUCCESS(rv, rv); nsAutoCharBuffer fileData; - if (!fileData.EnsureElemCapacity(size + 1)) { + if (!fileData.SetLength(size + 1)) { ReportEncodingMemoryError(mElement, aFile, size + 1); return NS_ERROR_OUT_OF_MEMORY; } PRUint32 bytesRead; - rv = fileStream->Read(fileData.get(), size, &bytesRead); + rv = fileStream->Read(fileData.Elements(), size, &bytesRead); NS_ASSERTION(NS_SUCCEEDED(rv) && bytesRead == size, "fileStream->Read failed"); @@ -492,7 +492,7 @@ nsXFormsUploadElement::EncodeFileContents(nsIFile *aFile, PRUint16 aType, if (aType == nsISchemaBuiltinType::BUILTIN_TYPE_BASE64BINARY) { // encode file contents *aResult = nsnull; - char *buffer = PL_Base64Encode(fileData.get(), bytesRead, nsnull); + char *buffer = PL_Base64Encode(fileData.Elements(), bytesRead, nsnull); if (buffer) { *aResult = ToNewUnicode(nsDependentCString(buffer)); PR_Free(buffer); @@ -513,7 +513,7 @@ nsXFormsUploadElement::EncodeFileContents(nsIFile *aFile, PRUint16 aType, rv = NS_ERROR_OUT_OF_MEMORY; } else { // encode file contents - BinaryToHex(fileData.get(), bytesRead, &fileDataHex); + BinaryToHex(fileData.Elements(), bytesRead, &fileDataHex); fileDataHex[bytesRead * 2] = 0; *aResult = fileDataHex; } diff --git a/mozilla/gfx/src/windows/nsFontMetricsWin.cpp b/mozilla/gfx/src/windows/nsFontMetricsWin.cpp index 1256c34ec04..d6fbf78a31e 100644 --- a/mozilla/gfx/src/windows/nsFontMetricsWin.cpp +++ b/mozilla/gfx/src/windows/nsFontMetricsWin.cpp @@ -58,7 +58,7 @@ #include "prprf.h" #include "nsReadableUtils.h" #include "nsUnicodeRange.h" -#include "nsAutoBuffer.h" +#include "nsTArray.h" #define DEFAULT_TTF_SYMBOL_ENCODING "windows-1252" #define IS_RTL_PRESENTATION_FORM(c) ((0xfb1d <= (c)) && ((c)<= 0xfefc)) @@ -283,8 +283,8 @@ static nsFontCleanupObserver *gFontCleanupObserver; #undef CHAR_BUFFER_SIZE #define CHAR_BUFFER_SIZE 1024 -typedef nsAutoBuffer nsAutoCharBuffer; -typedef nsAutoBuffer nsAutoChar16Buffer; +typedef nsAutoTArray nsAutoCharBuffer; +typedef nsAutoTArray nsAutoChar16Buffer; class nsFontSubset : public nsFontWin { @@ -701,10 +701,10 @@ GetNAME(HDC aDC, nsString* aName, PRBool* aIsSymbolEncoding = nsnull) return eGetName_OtherError; } nsAutoFontDataBuffer buffer; - if (!buffer.EnsureElemCapacity(len)) { + if (!buffer.SetLength(len)) { return eGetName_OtherError; } - PRUint8* buf = buffer.get(); + PRUint8* buf = buffer.Elements(); DWORD newLen = GetFontData(aDC, NAME, 0, buf, len); if (newLen != len) { @@ -805,10 +805,10 @@ GetSpaces(HDC aDC, PRBool* aIsCFFOutline, PRUint32* aMaxGlyph, if ((len == GDI_ERROR) || (!len)) { return NS_ERROR_FAILURE; } - if (!aIsSpace.EnsureElemCapacity(len)) { + if (!aIsSpace.SetLength(len)) { return NS_ERROR_OUT_OF_MEMORY; } - PRUint8* buf = aIsSpace.get(); + PRUint8* buf = aIsSpace.Elements(); DWORD newLen = GetFontData(aDC, LOCA, 0, buf, len); if (newLen != len) { return NS_ERROR_FAILURE; @@ -1429,8 +1429,8 @@ ConvertUnicodeToGlyph(const PRUnichar* aSrc, PRInt32 aSrcLength, return NS_ERROR_UNEXPECTED; } - if (!aResult.EnsureElemCapacity(aDestLength)) return NS_ERROR_OUT_OF_MEMORY; - char* str = aResult.get(); + if (!aResult.SetLength(aDestLength)) return NS_ERROR_OUT_OF_MEMORY; + char* str = aResult.Elements(); aConverter->Convert(aSrc, &aSrcLength, str, &aDestLength); @@ -1680,10 +1680,10 @@ nsFontMetricsWin::GetFontCCMAP(HDC aDC, const char* aShortName, return nsnull; } nsAutoFontDataBuffer buffer; - if (!buffer.EnsureElemCapacity(len)) { + if (!buffer.SetLength(len)) { return nsnull; } - PRUint8* buf = buffer.get(); + PRUint8* buf = buffer.Elements(); DWORD newLen = GetFontData(aDC, CMAP, 0, buf, len); if (newLen != len) { return nsnull; @@ -1938,10 +1938,10 @@ GetGlyphIndices(HDC aDC, if ((len == GDI_ERROR) || (!len)) { return NS_ERROR_UNEXPECTED; } - if (!buffer.EnsureElemCapacity(len)) { + if (!buffer.SetLength(len)) { return NS_ERROR_OUT_OF_MEMORY; } - buf = buffer.get(); + buf = buffer.Elements(); DWORD newLen = GetFontData(aDC, CMAP, 0, buf, len); if (newLen != len) { return NS_ERROR_UNEXPECTED; @@ -2034,10 +2034,10 @@ GetGlyphIndices(HDC aDC, PRUint16* idDelta = startCode + segCount; PRUint16* idRangeOffset = idDelta + segCount; - if (!aResult.EnsureElemCapacity(aLength)) { + if (!aResult.SetLength(aLength)) { return NS_ERROR_OUT_OF_MEMORY; } - PRUnichar* result = aResult.get(); + PRUnichar* result = aResult.Elements(); for (i = 0; i < aLength; ++i) { result[i] = GetGlyphIndex(segCount, endCode, startCode, idRangeOffset, idDelta, end, @@ -2146,7 +2146,7 @@ nsGlyphAgent::GetGlyphMetrics(HDC aDC, if (0 == aGlyphIndex) { // caller doesn't know the glyph index, so find it nsAutoChar16Buffer buf; if (NS_SUCCEEDED(GetGlyphIndices(aDC, nsnull, &aChar, 1, buf))) - aGlyphIndex = *(buf.get()); + aGlyphIndex = *(buf.Elements()); } if (0 < aGlyphIndex) { return GetGlyphOutlineA(aDC, aGlyphIndex, GGO_METRICS | GGO_GLYPH_INDEX, aGlyphMetrics, 0, nsnull, &mMat); @@ -4394,7 +4394,7 @@ nsFontWinUnicode::GetBoundingMetrics(HDC aDC, } } - return GetBoundingMetricsCommon(aDC, mOverhangCorrection, aString, aLength, aBoundingMetrics, buffer.get()); + return GetBoundingMetricsCommon(aDC, mOverhangCorrection, aString, aLength, aBoundingMetrics, buffer.Elements()); } #ifdef NS_DEBUG @@ -4433,9 +4433,9 @@ nsFontWinNonUnicode::GetWidth(HDC aDC, const PRUnichar* aString, SIZE size; if (!mIsWide) - ::GetTextExtentPoint32A(aDC, buffer.get(), destLength, &size); + ::GetTextExtentPoint32A(aDC, buffer.Elements(), destLength, &size); else - ::GetTextExtentPoint32W(aDC, (const PRUnichar*) buffer.get(), destLength / 2, &size); + ::GetTextExtentPoint32W(aDC, (const PRUnichar*) buffer.Elements(), destLength / 2, &size); size.cx -= mOverhangCorrection; return size.cx; @@ -4455,9 +4455,9 @@ nsFontWinNonUnicode::DrawString(HDC aDC, PRInt32 aX, PRInt32 aY, } if (!mIsWide) - NS_ExtTextOutA(aDC, this, aX, aY, 0, NULL, buffer.get(), aLength, NULL); + NS_ExtTextOutA(aDC, this, aX, aY, 0, NULL, buffer.Elements(), aLength, NULL); else - NS_ExtTextOutW(aDC, this, aX, aY, 0, NULL, (const PRUnichar*) buffer.get(), destLength / 2, NULL); + NS_ExtTextOutW(aDC, this, aX, aY, 0, NULL, (const PRUnichar*) buffer.Elements(), destLength / 2, NULL); } #ifdef MOZ_MATHML @@ -4486,7 +4486,7 @@ nsFontWinNonUnicode::GetBoundingMetrics(HDC aDC, if (gGlyphAgent.GetState() != eGlyphAgent_UNICODE) { // we are on a platform that doesn't implement GetGlyphOutlineW() // we need to use glyph indices - rv = GetGlyphIndices(aDC, &mCMAP, (const PRUnichar*)buffer.get(), destLength / 2, buf); + rv = GetGlyphIndices(aDC, &mCMAP, (const PRUnichar*)buffer.Elements(), destLength / 2, buf); if (NS_FAILED(rv)) { return rv; } @@ -4494,12 +4494,12 @@ nsFontWinNonUnicode::GetBoundingMetrics(HDC aDC, // buffer.mBuffer is now a pseudo-Unicode string so that we can use // GetBoundingMetricsCommon() also used by nsFontWinUnicode. - return GetBoundingMetricsCommon(aDC, mOverhangCorrection, (const PRUnichar*)buffer.get(), - destLength / 2, aBoundingMetrics, buf.get()); + return GetBoundingMetricsCommon(aDC, mOverhangCorrection, (const PRUnichar*)buffer.Elements(), + destLength / 2, aBoundingMetrics, buf.Elements()); } - return GetBoundingMetricsCommonA(aDC, mOverhangCorrection, buffer.get(), destLength, + return GetBoundingMetricsCommonA(aDC, mOverhangCorrection, buffer.Elements(), destLength, aBoundingMetrics); } @@ -4544,11 +4544,11 @@ SubstituteChars(PRBool aDisplayUnicode, #ifdef WINCE // Unicode backend on WINCE... Substitute nothing. - if (!aResult.EnsureElemCapacity(aLength)) + if (!aResult.SetLength(aLength)) return NS_ERROR_OUT_OF_MEMORY; *aCount = aLength; - memcpy(aResult.get(), aString, aLength * sizeof(PRUnichar)); + memcpy(aResult.Elements(), aString, aLength * sizeof(PRUnichar)); return NS_OK; #else @@ -4582,10 +4582,10 @@ SubstituteChars(PRBool aDisplayUnicode, if (NS_SUCCEEDED(res)) { *aCount = conv.Length(); if (*aCount > 0) { - if (!aResult.EnsureElemCapacity(*aCount)) { + if (!aResult.SetLength(*aCount)) { return NS_ERROR_OUT_OF_MEMORY; } - result = aResult.get(); + result = aResult.Elements(); PRUnichar* u = result; const char* c = conv.get(); for (; *c; ++c, ++u) { @@ -4597,8 +4597,8 @@ SubstituteChars(PRBool aDisplayUnicode, } // we reach here if we couldn't transliterate, so fallback to question marks - if (!aResult.EnsureElemCapacity(aLength)) return NS_ERROR_OUT_OF_MEMORY; - result = aResult.get(); + if (!aResult.SetLength(aLength)) return NS_ERROR_OUT_OF_MEMORY; + result = aResult.Elements(); for (PRUint32 i = 0; i < aLength; i++) { result[i] = NS_REPLACEMENT_CHAR; } @@ -4618,7 +4618,7 @@ nsFontWinSubstitute::GetWidth(HDC aDC, const PRUnichar* aString, if (NS_FAILED(rv) || !aLength) return 0; SIZE size; - ::GetTextExtentPoint32W(aDC, buffer.get(), aLength, &size); + ::GetTextExtentPoint32W(aDC, buffer.Elements(), aLength, &size); size.cx -= mOverhangCorrection; return size.cx; @@ -4634,7 +4634,7 @@ nsFontWinSubstitute::DrawString(HDC aDC, PRInt32 aX, PRInt32 aY, nsresult rv = SubstituteChars(PR_FALSE, aString, aLength, buffer, &aLength); if (NS_FAILED(rv) || !aLength) return; - NS_ExtTextOutW(aDC, this, aX, aY, 0, NULL, buffer.get(), aLength, NULL); + NS_ExtTextOutW(aDC, this, aX, aY, 0, NULL, buffer.Elements(), aLength, NULL); } #ifdef MOZ_MATHML @@ -4661,14 +4661,14 @@ nsFontWinSubstitute::GetBoundingMetrics(HDC aDC, if (gGlyphAgent.GetState() != eGlyphAgent_UNICODE) { // we are on a platform that doesn't implement GetGlyphOutlineW() // we better get all glyph indices in one swoop - rv = GetGlyphIndices(aDC, &mCMAP, buffer.get(), aLength, buf); + rv = GetGlyphIndices(aDC, &mCMAP, buffer.Elements(), aLength, buf); if (NS_FAILED(rv)) { return rv; } } - return GetBoundingMetricsCommon(aDC, mOverhangCorrection, buffer.get(), aLength, - aBoundingMetrics, buf.get()); + return GetBoundingMetricsCommon(aDC, mOverhangCorrection, buffer.Elements(), aLength, + aBoundingMetrics, buf.Elements()); } #ifdef NS_DEBUG @@ -4800,8 +4800,8 @@ nsFontSubset::Convert(const PRUnichar* aString, PRUint32 aLength, int nb = WideCharToMultiByte(mCodePage, 0, aString, aLength, nsnull, 0, nsnull, nsnull); - if (!nb || !aResult.EnsureElemCapacity(nb)) return; - char* buf = aResult.get(); + if (!nb || !aResult.SetLength(nb)) return; + char* buf = aResult.Elements(); // Convert the Unicode string to ANSI *aResultLength = WideCharToMultiByte(mCodePage, 0, aString, aLength, buf, nb, nsnull, nsnull); @@ -4814,7 +4814,7 @@ nsFontSubset::GetWidth(HDC aDC, const PRUnichar* aString, PRUint32 aLength) Convert(aString, aLength, buffer, &aLength); if (aLength) { SIZE size; - ::GetTextExtentPoint32A(aDC, buffer.get(), aLength, &size); + ::GetTextExtentPoint32A(aDC, buffer.Elements(), aLength, &size); size.cx -= mOverhangCorrection; return size.cx; } @@ -4828,7 +4828,7 @@ nsFontSubset::DrawString(HDC aDC, PRInt32 aX, PRInt32 aY, nsAutoCharBuffer buffer; Convert(aString, aLength, buffer, &aLength); if (aLength) { - NS_ExtTextOutA(aDC, this, aX, aY, 0, NULL, buffer.get(), aLength, NULL); + NS_ExtTextOutA(aDC, this, aX, aY, 0, NULL, buffer.Elements(), aLength, NULL); } } @@ -4843,7 +4843,7 @@ nsFontSubset::GetBoundingMetrics(HDC aDC, nsAutoCharBuffer buffer; Convert(aString, aLength, buffer, &aLength); if (aLength) { - return GetBoundingMetricsCommonA(aDC, mOverhangCorrection, buffer.get(), aLength, + return GetBoundingMetricsCommonA(aDC, mOverhangCorrection, buffer.Elements(), aLength, aBoundingMetrics); } return NS_OK; @@ -4926,11 +4926,11 @@ nsFontSubsetSubstitute::Convert(const PRUnichar* aString, PRUint32 aLength, } if (!aLength) { // this is the case where the substitute string collapsed to nothingness - *(aResult.get()) = '\0'; + *(aResult.Elements()) = '\0'; *aResultLength = 0; return; } - nsFontSubset::Convert(buffer.get(), aLength, aResult, aResultLength); + nsFontSubset::Convert(buffer.Elements(), aLength, aResult, aResultLength); } nsFontWinA::nsFontWinA(LOGFONT* aLogFont, HFONT aFont, PRUint16* aCCMap) diff --git a/mozilla/gfx/thebes/public/gfxOS2Fonts.h b/mozilla/gfx/thebes/public/gfxOS2Fonts.h index 79e3e6f9bfb..62723a7895c 100644 --- a/mozilla/gfx/thebes/public/gfxOS2Fonts.h +++ b/mozilla/gfx/thebes/public/gfxOS2Fonts.h @@ -49,7 +49,6 @@ #include "cairo-ft.h" // includes fontconfig.h, too #include -#include "nsAutoBuffer.h" #include "nsICharsetConverterManager.h" class gfxOS2Font : public gfxFont { diff --git a/mozilla/gfx/thebes/src/gfxWindowsFonts.cpp b/mozilla/gfx/thebes/src/gfxWindowsFonts.cpp index 679d0ad9d47..8111d5c8d1d 100644 --- a/mozilla/gfx/thebes/src/gfxWindowsFonts.cpp +++ b/mozilla/gfx/thebes/src/gfxWindowsFonts.cpp @@ -58,7 +58,7 @@ #include -#include "nsAutoBuffer.h" +#include "nsTArray.h" #include "nsUnicodeRange.h" #include "nsUnicharUtils.h" @@ -651,15 +651,15 @@ SetupTextRunFromGlyphs(gfxTextRun *aRun, WCHAR *aGlyphs, HDC aDC, return PR_FALSE; SIZE size; - nsAutoBuffer partialWidthArray; - if (!partialWidthArray.EnsureElemCapacity(length)) + nsAutoTArray partialWidthArray; + if (!partialWidthArray.SetLength(length)) return PR_FALSE; BOOL success = GetTextExtentExPointI(aDC, (WORD*) aGlyphs, length, INT_MAX, NULL, - partialWidthArray.get(), + partialWidthArray.Elements(), &size); if (!success) return PR_FALSE; @@ -701,14 +701,14 @@ gfxWindowsFontGroup::InitTextRunGDI(gfxContext *aContext, gfxTextRun *aRun, nsRefPtr font = GetFontAt(0); DCFromContext dc(aContext); if (SetupDCFont(dc, font)) { - nsAutoBuffer glyphArray; - if (!glyphArray.EnsureElemCapacity(aLength)) + nsAutoTArray glyphArray; + if (!glyphArray.SetLength(aLength)) return; - DWORD ret = GetGlyphIndicesA(dc, aString, aLength, (WORD*) glyphArray.get(), + DWORD ret = GetGlyphIndicesA(dc, aString, aLength, (WORD*) glyphArray.Elements(), GGI_MARK_NONEXISTING_GLYPHS); if (ret != GDI_ERROR && - SetupTextRunFromGlyphs(aRun, glyphArray.get(), dc, font)) + SetupTextRunFromGlyphs(aRun, glyphArray.Elements(), dc, font)) return; } @@ -725,14 +725,14 @@ gfxWindowsFontGroup::InitTextRunGDI(gfxContext *aContext, gfxTextRun *aRun, nsRefPtr font = GetFontAt(0); DCFromContext dc(aContext); if (SetupDCFont(dc, font)) { - nsAutoBuffer glyphArray; - if (!glyphArray.EnsureElemCapacity(aLength)) + nsAutoTArray glyphArray; + if (!glyphArray.SetLength(aLength)) return; - DWORD ret = GetGlyphIndicesW(dc, aString, aLength, (WORD*) glyphArray.get(), + DWORD ret = GetGlyphIndicesW(dc, aString, aLength, (WORD*) glyphArray.Elements(), GGI_MARK_NONEXISTING_GLYPHS); if (ret != GDI_ERROR && - SetupTextRunFromGlyphs(aRun, glyphArray.get(), dc, font)) + SetupTextRunFromGlyphs(aRun, glyphArray.Elements(), dc, font)) return; } @@ -886,9 +886,9 @@ public: mNumGlyphs(0), mMaxGlyphs((int)(1.5 * aLength) + 16), mFontSelected(PR_FALSE) { - mGlyphs.EnsureElemCapacity(mMaxGlyphs); - mClusters.EnsureElemCapacity(mItemLength + 1); - mAttr.EnsureElemCapacity(mMaxGlyphs); + mGlyphs.SetLength(mMaxGlyphs); + mClusters.SetLength(mItemLength + 1); + mAttr.SetLength(mMaxGlyphs); } ~UniscribeItem() { @@ -926,12 +926,12 @@ public: rv = ScriptShape(shapeDC, mCurrentFont->ScriptCache(), str, mRangeLength, mMaxGlyphs, &sa, - mGlyphs.get(), mClusters.get(), - mAttr.get(), &mNumGlyphs); + mGlyphs.Elements(), mClusters.Elements(), + mAttr.Elements(), &mNumGlyphs); if (rv == E_OUTOFMEMORY) { - mGlyphs.AddElemCapacity(mMaxGlyphs); - mAttr.AddElemCapacity(mMaxGlyphs); + mGlyphs.SetLength(mMaxGlyphs); + mAttr.SetLength(mMaxGlyphs); mMaxGlyphs *= 2; continue; } @@ -949,7 +949,7 @@ public: } #ifdef DEBUG_pavlov if (rv == USP_E_SCRIPT_NOT_IN_FONT) { - ScriptGetCMap(mDC, mCurrentFont->ScriptCache(), str, mRangeString, 0, mGlyphs.get()); + ScriptGetCMap(mDC, mCurrentFont->ScriptCache(), str, mRangeString, 0, mGlyphs.Elements()); PRUnichar foo[LF_FACESIZE+1]; GetTextFaceW(mDC, LF_FACESIZE, foo); printf("bah\n"); @@ -989,16 +989,16 @@ public: HRESULT Place() { HRESULT rv; - mOffsets.EnsureElemCapacity(mNumGlyphs); - mAdvances.EnsureElemCapacity(mNumGlyphs); + mOffsets.SetLength(mNumGlyphs); + mAdvances.SetLength(mNumGlyphs); HDC placeDC = nsnull; while (PR_TRUE) { rv = ScriptPlace(placeDC, mCurrentFont->ScriptCache(), - mGlyphs.get(), mNumGlyphs, - mAttr.get(), &mScriptItem->a, - mAdvances.get(), mOffsets.get(), NULL); + mGlyphs.Elements(), mNumGlyphs, + mAttr.Elements(), &mScriptItem->a, + mAdvances.Elements(), mOffsets.Elements(), NULL); if (rv == E_PENDING) { SelectFont(); @@ -1457,12 +1457,12 @@ private: #define AVERAGE_ITEM_LENGTH 40 - nsAutoBuffer mGlyphs; - nsAutoBuffer mClusters; - nsAutoBuffer mAttr; + nsAutoTArray mGlyphs; + nsAutoTArray mClusters; + nsAutoTArray mAttr; - nsAutoBuffer mOffsets; - nsAutoBuffer mAdvances; + nsAutoTArray mOffsets; + nsAutoTArray mAdvances; #undef AVERAGE_ITEM_LENGTH diff --git a/mozilla/intl/locale/src/nsLocaleService.cpp b/mozilla/intl/locale/src/nsLocaleService.cpp index 180bc8d0827..6e8eea9822e 100644 --- a/mozilla/intl/locale/src/nsLocaleService.cpp +++ b/mozilla/intl/locale/src/nsLocaleService.cpp @@ -44,7 +44,7 @@ #include "nsReadableUtils.h" #include "nsCRT.h" #include "prprf.h" -#include "nsAutoBuffer.h" +#include "nsTArray.h" #include @@ -265,16 +265,16 @@ nsLocaleService::nsLocaleService(void) CFStringRef userLocaleStr = ::CFLocaleGetIdentifier(userLocaleRef); ::CFRetain(userLocaleStr); - nsAutoBuffer buffer; + nsAutoTArray buffer; int size = ::CFStringGetLength(userLocaleStr); - if (buffer.EnsureElemCapacity(size)) + if (buffer.SetLength(size)) { CFRange range = ::CFRangeMake(0, size); - ::CFStringGetCharacters(userLocaleStr, range, buffer.get()); - buffer.get()[size] = 0; + ::CFStringGetCharacters(userLocaleStr, range, buffer.Elements()); + buffer[size] = 0; // Convert the locale string to the format that Mozilla expects - nsAutoString xpLocale(buffer.get()); + nsAutoString xpLocale(buffer.Elements()); xpLocale.ReplaceChar('_', '-'); nsresult rv = NewLocale(xpLocale, getter_AddRefs(mSystemLocale)); diff --git a/mozilla/modules/libpr0n/decoders/icon/mac/nsIconChannelCocoa.mm b/mozilla/modules/libpr0n/decoders/icon/mac/nsIconChannelCocoa.mm index 19be7e1af3f..1372afd6f27 100644 --- a/mozilla/modules/libpr0n/decoders/icon/mac/nsIconChannelCocoa.mm +++ b/mozilla/modules/libpr0n/decoders/icon/mac/nsIconChannelCocoa.mm @@ -57,7 +57,7 @@ #include "nsILocalFileMac.h" #include "nsIFileURL.h" #include "nsInt64.h" -#include "nsAutoBuffer.h" +#include "nsTArray.h" #include @@ -313,11 +313,11 @@ nsresult nsIconChannel::MakeInputStream(nsIInputStream** _retval, PRBool nonBloc // create our buffer PRInt32 bufferCapacity = 2 + desiredImageSize * desiredImageSize * 4; - nsAutoBuffer iconBuffer; // initial size is for 16x16 - if (!iconBuffer.EnsureElemCapacity(bufferCapacity)) + nsAutoTArray iconBuffer; // initial size is for 16x16 + if (!iconBuffer.SetLength(bufferCapacity)) return NS_ERROR_OUT_OF_MEMORY; - PRUint8* iconBufferPtr = iconBuffer.get(); + PRUint8* iconBufferPtr = iconBuffer.Elements(); // write header data into buffer *iconBufferPtr++ = desiredImageSize; @@ -348,7 +348,7 @@ nsresult nsIconChannel::MakeInputStream(nsIInputStream** _retval, PRBool nonBloc #endif } - NS_ASSERTION(iconBufferPtr == iconBuffer.get() + bufferCapacity, + NS_ASSERTION(iconBufferPtr == iconBuffer.Elements() + bufferCapacity, "buffer size miscalculation"); // Now, create a pipe and stuff our data into it @@ -358,7 +358,7 @@ nsresult nsIconChannel::MakeInputStream(nsIInputStream** _retval, PRBool nonBloc if (NS_SUCCEEDED(rv)) { PRUint32 written; - rv = outStream->Write((char*)iconBuffer.get(), bufferCapacity, &written); + rv = outStream->Write((char*)iconBuffer.Elements(), bufferCapacity, &written); if (NS_SUCCEEDED(rv)) NS_IF_ADDREF(*_retval = inStream); } diff --git a/mozilla/suite/browser/src/nsBookmarksService.cpp b/mozilla/suite/browser/src/nsBookmarksService.cpp index 55d1603a838..0fb40a67d5c 100644 --- a/mozilla/suite/browser/src/nsBookmarksService.cpp +++ b/mozilla/suite/browser/src/nsBookmarksService.cpp @@ -95,7 +95,7 @@ #include "nsICollation.h" #include "nsVoidArray.h" #include "nsUnicharUtils.h" -#include "nsAutoBuffer.h" +#include "nsTArray.h" #include "nsINetUtil.h" #if defined(XP_WIN) || defined(XP_OS2) @@ -742,17 +742,17 @@ BookmarkParser::DecodeBuffer(nsString &line, char *buf, PRUint32 aLength) PRInt32 unicharBufLen = 0; mUnicodeDecoder->GetMaxLength(aBuffer, aLength, &unicharBufLen); - nsAutoBuffer stackBuffer; - if (!stackBuffer.EnsureElemCapacity(unicharBufLen + 1)) + nsAutoTArray stackBuffer; + if (!stackBuffer.SetLength(unicharBufLen + 1)) return NS_ERROR_OUT_OF_MEMORY; do { PRInt32 srcLength = aLength; PRInt32 unicharLength = unicharBufLen; - PRUnichar *unichars = stackBuffer.get(); + PRUnichar *unichars = stackBuffer.Elements(); - rv = mUnicodeDecoder->Convert(aBuffer, &srcLength, stackBuffer.get(), &unicharLength); + rv = mUnicodeDecoder->Convert(aBuffer, &srcLength, stackBuffer.Elements(), &unicharLength); unichars[unicharLength]=0; //add this since the unicode converters can't be trusted to do so. // Move the nsParser.cpp 00 -> space hack to here so it won't break UCS2 file diff --git a/mozilla/uriloader/exthandler/mac/nsOSHelperAppService.cpp b/mozilla/uriloader/exthandler/mac/nsOSHelperAppService.cpp index 0e5016ba2e5..5e8fc8f71f5 100644 --- a/mozilla/uriloader/exthandler/mac/nsOSHelperAppService.cpp +++ b/mozilla/uriloader/exthandler/mac/nsOSHelperAppService.cpp @@ -40,7 +40,7 @@ #include "nsOSHelperAppService.h" #include "nsISupports.h" #include "nsString.h" -#include "nsAutoBuffer.h" +#include "nsTArray.h" #include "nsXPIDLString.h" #include "nsIURL.h" #include "nsILocalFile.h" @@ -125,12 +125,12 @@ NS_IMETHODIMP nsOSHelperAppService::GetApplicationDescription(const nsACString& (CFStringRef)::CFBundleGetValueForInfoDictionaryKey(handlerBundle, kCFBundleNameKey); if (bundleName) { - nsAutoBuffer buffer; + nsAutoTArray buffer; CFIndex bundleNameLength = ::CFStringGetLength(bundleName); - buffer.EnsureElemCapacity(bundleNameLength); + buffer.SetLength(bundleNameLength); ::CFStringGetCharacters(bundleName, CFRangeMake(0, bundleNameLength), - buffer.get()); - _retval.Assign(buffer.get(), bundleNameLength); + buffer.Elements()); + _retval.Assign(buffer.Elements(), bundleNameLength); rv = NS_OK; } diff --git a/mozilla/widget/src/os2/nsOS2Uni.cpp b/mozilla/widget/src/os2/nsOS2Uni.cpp index 0b14aacc993..2230ff8a01f 100644 --- a/mozilla/widget/src/os2/nsOS2Uni.cpp +++ b/mozilla/widget/src/os2/nsOS2Uni.cpp @@ -147,12 +147,12 @@ WideCharToMultiByte(int aCodePage, const PRUnichar* aSrc, if (NS_FAILED(uco->GetMaxLength(aSrc, aSrcLength, &aResultLength))) { return NS_ERROR_UNEXPECTED; } - if (!aResult.EnsureElemCapacity(aResultLength + 1)) + if (!aResult.SetLength(aResultLength + 1)) return NS_ERROR_OUT_OF_MEMORY; - char* str = aResult.get(); + char* str = aResult.Elements(); rv = uco->Convert(aSrc, &aSrcLength, str, &aResultLength); - aResult.get()[aResultLength] = '\0'; + aResult[aResultLength] = '\0'; return rv; } @@ -171,11 +171,11 @@ MultiByteToWideChar(int aCodePage, const char* aSrc, if (NS_FAILED(uco->GetMaxLength(aSrc, aSrcLength, &aResultLength))) { return NS_ERROR_UNEXPECTED; } - if (!aResult.EnsureElemCapacity(aResultLength + 1)) + if (!aResult.SetLength(aResultLength + 1)) return NS_ERROR_OUT_OF_MEMORY; - PRUnichar* str = aResult.get(); + PRUnichar* str = aResult.Elements(); rv = uco->Convert(aSrc, &aSrcLength, str, &aResultLength); - aResult.get()[aResultLength] = '\0'; + aResult[aResultLength] = '\0'; return rv; } diff --git a/mozilla/widget/src/os2/nsOS2Uni.h b/mozilla/widget/src/os2/nsOS2Uni.h index 65a8b2b0336..1069e086464 100644 --- a/mozilla/widget/src/os2/nsOS2Uni.h +++ b/mozilla/widget/src/os2/nsOS2Uni.h @@ -40,7 +40,7 @@ #define INCL_WIN #include #include -#include "nsAutoBuffer.h" +#include "nsTArray.h" #include "nsICharsetConverterManager.h" #include "gfxCore.h" @@ -58,8 +58,8 @@ private: }; #define CHAR_BUFFER_SIZE 1024 -typedef nsAutoBuffer nsAutoCharBuffer; -typedef nsAutoBuffer nsAutoChar16Buffer; +typedef nsAutoTArray nsAutoCharBuffer; +typedef nsAutoTArray nsAutoChar16Buffer; nsresult WideCharToMultiByte(int aCodePage, const PRUnichar* aSrc, PRInt32 aSrcLength, nsAutoCharBuffer& aResult, diff --git a/mozilla/xpcom/ds/Makefile.in b/mozilla/xpcom/ds/Makefile.in index 06524be7dc5..44e11c14199 100644 --- a/mozilla/xpcom/ds/Makefile.in +++ b/mozilla/xpcom/ds/Makefile.in @@ -107,7 +107,6 @@ EXPORTS = \ nsTextFormatter.h \ nsValueArray.h \ nsStringEnumerator.h \ - nsAutoBuffer.h \ nsHashPropertyBag.h \ nsWhitespaceTokenizer.h \ $(NULL) diff --git a/mozilla/xpcom/glue/nsTArray.h b/mozilla/xpcom/glue/nsTArray.h index 372995edf86..e6b4516eae5 100644 --- a/mozilla/xpcom/glue/nsTArray.h +++ b/mozilla/xpcom/glue/nsTArray.h @@ -180,7 +180,12 @@ class nsTArrayElementTraits { public: // Invoke the default constructor in place. static inline void Construct(E *e) { - new (static_cast(e)) E(); + // Do NOT call "E()"! That triggers C++ "default initialization" + // which zeroes out POD ("plain old data") types such as regular ints. + // We don't want that because it can be a performance issue and people + // don't expect it; nsTArray should work like a regular C/C++ array in + // this respect. + new (static_cast(e)) E; } // Invoke the copy-constructor in place. template diff --git a/mozilla/xpcom/io/nsLocalFileOSX.cpp b/mozilla/xpcom/io/nsLocalFileOSX.cpp index 76c64ecdc36..ab3e4a46784 100644 --- a/mozilla/xpcom/io/nsLocalFileOSX.cpp +++ b/mozilla/xpcom/io/nsLocalFileOSX.cpp @@ -58,7 +58,7 @@ #include "MoreFilesX.h" #include "FSCopyObject.h" -#include "nsAutoBuffer.h" +#include "nsTArray.h" #include "nsTraceRefcntImpl.h" // Mac Includes @@ -483,7 +483,7 @@ NS_IMETHODIMP nsLocalFile::Create(PRUint32 type, PRUint32 permissions) CFURLRef pathURLRef = mBaseRef; FSRef pathFSRef; CFStringRef leafStrRef = nsnull; - nsAutoBuffer buffer; + nsAutoTArray buffer; Boolean success; // Work backwards through the path to find the last node which @@ -494,11 +494,11 @@ NS_IMETHODIMP nsLocalFile::Create(PRUint32 type, PRUint32 permissions) if (!leafStrRef) break; CFIndex leafLen = ::CFStringGetLength(leafStrRef); - if (!buffer.EnsureElemCapacity(leafLen + 1)) + if (!buffer.SetLength(leafLen + 1)) break; - ::CFStringGetCharacters(leafStrRef, CFRangeMake(0, leafLen), buffer.get()); - buffer.get()[leafLen] = '\0'; - nonExtantNodes.AppendString(nsString(nsDependentString(buffer.get()))); + ::CFStringGetCharacters(leafStrRef, CFRangeMake(0, leafLen), buffer.Elements()); + buffer[leafLen] = '\0'; + nonExtantNodes.AppendString(nsString(nsDependentString(buffer.Elements()))); ::CFRelease(leafStrRef); leafStrRef = nsnull; @@ -2499,12 +2499,12 @@ static void CopyUTF8toUTF16NFC(const nsACString& aSrc, nsAString& aResult) if (chars) aResult.Assign(chars, length); else { - nsAutoBuffer buffer; - if (!buffer.EnsureElemCapacity(length)) + nsAutoTArray buffer; + if (!buffer.SetLength(length)) CopyUTF8toUTF16(aSrc, aResult); else { - CFStringGetCharacters(inStr, CFRangeMake(0, length), buffer.get()); - aResult.Assign(buffer.get(), length); + CFStringGetCharacters(inStr, CFRangeMake(0, length), buffer.Elements()); + aResult.Assign(buffer.Elements(), length); } } CFRelease(inStr); diff --git a/mozilla/xpcom/obsolete/nsFileSpecUnix.cpp b/mozilla/xpcom/obsolete/nsFileSpecUnix.cpp index 9d7c2984f23..8359e1ca695 100644 --- a/mozilla/xpcom/obsolete/nsFileSpecUnix.cpp +++ b/mozilla/xpcom/obsolete/nsFileSpecUnix.cpp @@ -50,7 +50,7 @@ #include "xpcom-private.h" #include "nsError.h" #include "prio.h" /* for PR_Rename */ -#include "nsAutoBuffer.h" +#include "nsTArray.h" #if defined(_SCO_DS) #define _SVID3 /* for statvfs.h */ @@ -764,10 +764,10 @@ static void CopyUTF8toUTF16NFC(const nsACString& aSrc, nsAString& aResult) if (chars) aResult.Assign(chars, length); else { - nsAutoBuffer buffer; - if (buffer.EnsureElemCapacity(length)) { - CFStringGetCharacters(inStr, CFRangeMake(0, length), buffer.get()); - aResult.Assign(buffer.get(), length); + nsAutoTArray buffer; + if (buffer.SetLength(length)) { + CFStringGetCharacters(inStr, CFRangeMake(0, length), buffer.Elements()); + aResult.Assign(buffer.Elements(), length); } else CopyUTF8toUTF16(aSrc, aResult);