--- a/browser/components/migration/src/nsSafariProfileMigrator.cpp
+++ b/browser/components/migration/src/nsSafariProfileMigrator.cpp
@@ -59,17 +59,17 @@
#include "nsIRDFService.h"
#include "nsIServiceManager.h"
#include "nsIStringBundle.h"
#include "nsISupportsArray.h"
#include "nsISupportsPrimitives.h"
#include "nsSafariProfileMigrator.h"
#include "nsToolkitCompsCID.h"
#include "nsNetUtil.h"
-#include "nsAutoBuffer.h"
+#include "nsTArray.h"
#include <Carbon/Carbon.h>
#define SAFARI_PREFERENCES_FILE_NAME NS_LITERAL_STRING("com.apple.Safari.plist")
#define SAFARI_BOOKMARKS_FILE_NAME NS_LITERAL_STRING("Bookmarks.plist")
#define SAFARI_HISTORY_FILE_NAME NS_LITERAL_STRING("History.plist")
#define SAFARI_COOKIES_FILE_NAME NS_LITERAL_STRING("Cookies.plist")
#define SAFARI_COOKIE_BEHAVIOR_FILE_NAME NS_LITERAL_STRING("com.apple.WebFoundation.plist")
@@ -306,56 +306,56 @@ FreeNullTerminatedString(char* aString)
}
PRBool
GetDictionaryStringValue(CFDictionaryRef aDictionary, CFStringRef aKey,
nsAString& aResult)
{
CFStringRef value = (CFStringRef)::CFDictionaryGetValue(aDictionary, aKey);
if (value) {
- nsAutoBuffer<UniChar, 1024> buffer;
+ nsAutoTArray<UniChar, 1024> 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;
}
PRBool
GetDictionaryCStringValue(CFDictionaryRef aDictionary, CFStringRef aKey,
nsACString& aResult, CFStringEncoding aEncoding)
{
CFStringRef value = (CFStringRef)::CFDictionaryGetValue(aDictionary, aKey);
if (value) {
- nsAutoBuffer<char, 1024> buffer;
+ nsAutoTArray<char, 1024> 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;
}
}
return PR_FALSE;
}
PRBool
GetArrayStringValue(CFArrayRef aArray, PRInt32 aIndex, nsAString& aResult)
{
CFStringRef value = (CFStringRef)::CFArrayGetValueAtIndex(aArray, aIndex);
if (value) {
- nsAutoBuffer<UniChar, 1024> buffer;
+ nsAutoTArray<UniChar, 1024> 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;
}
#define _SPM(type) nsSafariProfileMigrator::type
static
--- a/embedding/components/printingui/src/mac/nsPrintingPromptServiceX.cpp
+++ b/embedding/components/printingui/src/mac/nsPrintingPromptServiceX.cpp
@@ -47,17 +47,17 @@
#include "nsReadableUtils.h"
#include "nsIEmbeddingSiteWindow.h"
#include "nsIServiceManager.h"
#include "nsIWebBrowserChrome.h"
#include "nsIWindowWatcher.h"
#include "nsIPrintSettingsX.h"
#include "nsIDirectoryService.h"
#include "nsDirectoryServiceDefs.h"
-#include "nsAutoBuffer.h"
+#include "nsTArray.h"
#include "nsPDECommon.h"
// Printing Progress Includes
#include "nsPrintProgress.h"
#include "nsPrintProgressParams.h"
#include "nsIWebProgressListener.h"
@@ -93,21 +93,21 @@ static nsresult LoadPDEPlugIn()
static CFDictionaryRef ExtractCustomSettingsDict(PMPrintSettings nativePrintSettings)
{
CFDictionaryRef resultDict = nsnull;
UInt32 bytesNeeded;
OSStatus status = ::PMGetPrintSettingsExtendedData(nativePrintSettings, kAppPrintDialogAppOnlyKey, &bytesNeeded, NULL);
if (status == noErr) {
- nsAutoBuffer<UInt8, 512> dataBuffer;
- if (dataBuffer.EnsureElemCapacity(bytesNeeded)) {
- status = ::PMGetPrintSettingsExtendedData(nativePrintSettings, kAppPrintDialogAppOnlyKey, &bytesNeeded, dataBuffer.get());
+ nsAutoTArray<UInt8, 512> 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,
xmlData,
kCFPropertyListImmutable,
NULL);
CFRelease(xmlData);
}
@@ -123,20 +123,20 @@ GetDictionaryStringValue(CFDictionaryRef
{
aResult.Truncate();
CFTypeRef dictValue;
if ((dictValue = CFDictionaryGetValue(aDictionary, aKey)) &&
(CFGetTypeID(dictValue) == CFStringGetTypeID()))
{
CFIndex stringLen = CFStringGetLength((CFStringRef)dictValue);
- nsAutoBuffer<UniChar, 256> stringBuffer;
- if (stringBuffer.EnsureElemCapacity(stringLen + 1)) {
- ::CFStringGetCharacters((CFStringRef)dictValue, CFRangeMake(0, stringLen), stringBuffer.get());
- aResult.Assign(stringBuffer.get(), stringLen);
+ nsAutoTArray<UniChar, 256> stringBuffer;
+ if (stringBuffer.SetLength(stringLen + 1)) {
+ ::CFStringGetCharacters((CFStringRef)dictValue, CFRangeMake(0, stringLen), stringBuffer.Elements());
+ aResult.Assign(stringBuffer.Elements(), stringLen);
return PR_TRUE;
}
}
return PR_FALSE;
}
// returns success or failure (not the read value)
static PRBool
--- a/gfx/src/windows/nsFontMetricsWin.cpp
+++ b/gfx/src/windows/nsFontMetricsWin.cpp
@@ -53,17 +53,17 @@
#include "nsTextFormatter.h"
#include "nsIPersistentProperties2.h"
#include "nsNetUtil.h"
#include "prmem.h"
#include "plhash.h"
#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))
#define NOT_SETUP 0x33
static PRBool gIsWIN95OR98 = NOT_SETUP;
PRBool IsWin95OrWin98()
@@ -278,18 +278,18 @@ NS_IMETHODIMP nsFontCleanupObserver::Obs
return NS_OK;
}
static nsFontCleanupObserver *gFontCleanupObserver;
#undef CHAR_BUFFER_SIZE
#define CHAR_BUFFER_SIZE 1024
-typedef nsAutoBuffer<char, CHAR_BUFFER_SIZE> nsAutoCharBuffer;
-typedef nsAutoBuffer<PRUnichar, CHAR_BUFFER_SIZE> nsAutoChar16Buffer;
+typedef nsAutoTArray<char, CHAR_BUFFER_SIZE> nsAutoCharBuffer;
+typedef nsAutoTArray<PRUnichar, CHAR_BUFFER_SIZE> nsAutoChar16Buffer;
class nsFontSubset : public nsFontWin
{
public:
nsFontSubset();
virtual ~nsFontSubset();
virtual PRInt32 GetWidth(HDC aDC, const PRUnichar* aString,
@@ -696,20 +696,20 @@ GetNAME(HDC aDC, nsString* aName, PRBool
return eGetName_OtherError;
return (metrics.tmPitchAndFamily & TMPF_TRUETYPE) ?
eGetName_OtherError : eGetName_GDIError;
}
if (!len) {
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) {
return eGetName_OtherError;
}
PRUint8* p = buf + 2;
PRUint16 n = GET_SHORT(p);
p += 2;
@@ -800,20 +800,20 @@ GetSpaces(HDC aDC, PRBool* aIsCFFOutline
int isLong = GetIndexToLocFormat(aDC);
if (isLong < 0) {
return NS_ERROR_FAILURE;
}
len = GetFontData(aDC, LOCA, 0, nsnull, 0);
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;
}
if (isLong) {
DWORD longLen = ((len / 4) - 1);
*aMaxGlyph = longLen;
PRUint32* longBuf = (PRUint32*) buf;
@@ -1424,18 +1424,18 @@ ConvertUnicodeToGlyph(const PRUnichar* a
PRInt32& aDestLength, nsIUnicodeEncoder* aConverter,
PRBool aIsWide, nsAutoCharBuffer& aResult)
{
if (aIsWide &&
NS_FAILED(aConverter->GetMaxLength(aSrc, aSrcLength, &aDestLength))) {
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);
#ifdef IS_LITTLE_ENDIAN
// Convert BE UCS2 to LE UCS2 for 'wide' fonts
if (aIsWide) {
char* pstr = str;
while (pstr < str + aDestLength) {
@@ -1675,20 +1675,20 @@ nsFontMetricsWin::GetFontCCMAP(HDC aDC,
{
PRUint16 *ccmap = nsnull;
DWORD len = GetFontData(aDC, CMAP, 0, nsnull, 0);
if ((len == GDI_ERROR) || (!len)) {
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;
}
PRUint32 map[UCS2_MAP_LEN];
memset(map, 0, sizeof(map));
PRUint8* p = buf + sizeof(PRUint16); // skip version, move to numberSubtables
@@ -1933,20 +1933,20 @@ GetGlyphIndices(HDC aDC,
// Initialize as a 0-length CMAP, so that if there is an
// error with this CMAP, it will never be tried again.
if (aCMAP && *aCMAP) (*aCMAP)->mLength = 0;
len = GetFontData(aDC, CMAP, 0, nsnull, 0);
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;
}
PRUint8* p = buf + sizeof(PRUint16); // skip version, move to numberOfSubtables
PRUint16 n = GET_SHORT(p);
p += sizeof(PRUint16); // skip numberSubtables, move to the encoding subtables
PRUint16 i;
@@ -2029,20 +2029,20 @@ GetGlyphIndices(HDC aDC,
PRUint16* s = (PRUint16*) (buf + offset);
PRUint16 segCount = s[3] / 2;
PRUint16* endCode = &s[7];
PRUint16* startCode = endCode + segCount + 1;
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,
aString[i]);
}
return NS_OK;
}
@@ -2141,17 +2141,17 @@ nsGlyphAgent::GetGlyphMetrics(HDC
// Otherwise, we are on a platform that doesn't implement GetGlyphOutlineW()
// (see Q241358: The GetGlyphOutlineW Function Fails on Windows 95 & 98
// http://support.microsoft.com/support/kb/articles/Q241/3/58.ASP)
// we will use glyph indices as a work around.
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);
}
// if we ever reach here, something went wrong in GetGlyphIndices() above
// because the current font in aDC wasn't a Unicode font
return GDI_ERROR;
@@ -4389,17 +4389,17 @@ nsFontWinUnicode::GetBoundingMetrics(HDC
// we are on a platform that doesn't implement GetGlyphOutlineW()
// we need to use glyph indices
nsresult rv = GetGlyphIndices(aDC, &mCMAP, aString, aLength, buffer);
if (NS_FAILED(rv)) {
return rv;
}
}
- return GetBoundingMetricsCommon(aDC, mOverhangCorrection, aString, aLength, aBoundingMetrics, buffer.get());
+ return GetBoundingMetricsCommon(aDC, mOverhangCorrection, aString, aLength, aBoundingMetrics, buffer.Elements());
}
#ifdef NS_DEBUG
void
nsFontWinUnicode::DumpFontInfo()
{
printf("FontName: %s @%p\n", mName, this);
printf("FontType: nsFontWinUnicode\n");
@@ -4428,19 +4428,19 @@ nsFontWinNonUnicode::GetWidth(HDC aDC, c
PRInt32 destLength = aLength;
if (NS_FAILED(ConvertUnicodeToGlyph(aString, aLength, destLength,
mConverter, mIsWide, buffer))) {
return 0;
}
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;
}
void
nsFontWinNonUnicode::DrawString(HDC aDC, PRInt32 aX, PRInt32 aY,
const PRUnichar* aString, PRUint32 aLength)
@@ -4450,19 +4450,19 @@ nsFontWinNonUnicode::DrawString(HDC aDC,
PRInt32 destLength = aLength;
if (NS_FAILED(ConvertUnicodeToGlyph(aString, aLength, destLength,
mConverter, mIsWide, buffer))) {
return;
}
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
nsresult
nsFontWinNonUnicode::GetBoundingMetrics(HDC aDC,
const PRUnichar* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics)
@@ -4481,30 +4481,30 @@ nsFontWinNonUnicode::GetBoundingMetrics(
if (mIsWide) {
nsAutoChar16Buffer buf;
// at this stage, the glyph agent should have already been initialized
// given that it was used to compute the x-height in RealizeFont()
NS_ASSERTION(gGlyphAgent.GetState() != eGlyphAgent_UNKNOWN, "Glyph agent is not yet initialized");
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;
}
}
// 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 GetBoundingMetricsCommonA(aDC, mOverhangCorrection, buffer.get(), destLength,
+ return GetBoundingMetricsCommon(aDC, mOverhangCorrection, (const PRUnichar*)buffer.Elements(),
+ destLength / 2, aBoundingMetrics, buf.Elements());
+
+ }
+
+ return GetBoundingMetricsCommonA(aDC, mOverhangCorrection, buffer.Elements(), destLength,
aBoundingMetrics);
}
#ifdef NS_DEBUG
void
nsFontWinNonUnicode::DumpFontInfo()
{
printf("FontName: %s @%p\n", mName, this);
@@ -4539,21 +4539,21 @@ SubstituteChars(PRBool aDis
PRUint32 aLength,
nsAutoChar16Buffer& aResult,
PRUint32* aCount)
{
#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
nsresult res;
if (!gFontSubstituteConverter) {
CallCreateInstance(NS_SAVEASCHARSET_CONTRACTID, &gFontSubstituteConverter);
@@ -4577,33 +4577,33 @@ SubstituteChars(PRBool aDis
PRUnichar* result;
if (gFontSubstituteConverter) {
nsXPIDLCString conv;
nsAutoString tmp(aString, aLength); // we need to pass a null-terminated string
res = gFontSubstituteConverter->Convert(tmp.get(), getter_Copies(conv));
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) {
*u = *c;
}
}
return NS_OK;
}
}
// 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;
}
*aCount = aLength;
return NS_OK;
#endif // WINCE
}
@@ -4613,33 +4613,33 @@ nsFontWinSubstitute::GetWidth(HDC aDC, c
{
if (mIsForIgnorable)
return 0;
nsAutoChar16Buffer buffer;
nsresult rv = SubstituteChars(PR_FALSE, aString, aLength, buffer, &aLength);
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;
}
void
nsFontWinSubstitute::DrawString(HDC aDC, PRInt32 aX, PRInt32 aY,
const PRUnichar* aString, PRUint32 aLength)
{
if (mIsForIgnorable)
return;
nsAutoChar16Buffer buffer;
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
nsresult
nsFontWinSubstitute::GetBoundingMetrics(HDC aDC,
const PRUnichar* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics)
@@ -4656,24 +4656,24 @@ nsFontWinSubstitute::GetBoundingMetrics(
nsAutoChar16Buffer buf;
// at this stage, the glyph agent should have already been initialized
// given that it was used to compute the x-height in RealizeFont()
NS_ASSERTION(gGlyphAgent.GetState() != eGlyphAgent_UNKNOWN, "Glyph agent is not yet initialized");
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
void
nsFontWinSubstitute::DumpFontInfo()
{
printf("FontName: %s @%p\n", mIsForIgnorable ? "For the ignorable" : mName, this);
printf("FontType: nsFontWinSubstitute\n");
@@ -4795,60 +4795,60 @@ void
nsFontSubset::Convert(const PRUnichar* aString, PRUint32 aLength,
nsAutoCharBuffer& aResult, PRUint32* aResultLength)
{
*aResultLength = 0;
// Get the number of bytes needed for the conversion
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);
}
PRInt32
nsFontSubset::GetWidth(HDC aDC, const PRUnichar* aString, PRUint32 aLength)
{
nsAutoCharBuffer buffer;
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;
}
return 0;
}
void
nsFontSubset::DrawString(HDC aDC, PRInt32 aX, PRInt32 aY,
const PRUnichar* aString, PRUint32 aLength)
{
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);
}
}
#ifdef MOZ_MATHML
nsresult
nsFontSubset::GetBoundingMetrics(HDC aDC,
const PRUnichar* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics)
{
aBoundingMetrics.Clear();
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;
}
#ifdef NS_DEBUG
void
nsFontSubset::DumpFontInfo()
@@ -4921,21 +4921,21 @@ nsFontSubsetSubstitute::Convert(const PR
nsresult rv = SubstituteChars(PR_FALSE, aString, aLength, buffer, &aLength);
if (NS_FAILED(rv)) {
// this is the out-of-memory error case
*aResultLength = 0;
return;
}
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)
: nsFontWin(aLogFont, aFont, aCCMap)
{
if (aLogFont) {
mLogFont = *aLogFont;
}
--- a/gfx/thebes/public/gfxOS2Fonts.h
+++ b/gfx/thebes/public/gfxOS2Fonts.h
@@ -44,17 +44,16 @@
#include "nsDataHashtable.h"
#define INCL_GPI
#include <os2.h>
#include <cairo-os2.h>
#include "cairo-ft.h" // includes fontconfig.h, too
#include <freetype/tttables.h>
-#include "nsAutoBuffer.h"
#include "nsICharsetConverterManager.h"
class gfxOS2Font : public gfxFont {
public:
gfxOS2Font(const nsAString &aName, const gfxFontStyle *aFontStyle);
virtual ~gfxOS2Font();
virtual const gfxFont::Metrics& GetMetrics();
--- a/gfx/thebes/src/gfxWindowsFonts.cpp
+++ b/gfx/thebes/src/gfxWindowsFonts.cpp
@@ -53,17 +53,17 @@
#include "gfxFontTest.h"
#include "cairo.h"
#include "cairo-win32.h"
#include <windows.h>
-#include "nsAutoBuffer.h"
+#include "nsTArray.h"
#include "nsUnicodeRange.h"
#include "nsUnicharUtils.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsServiceManagerUtils.h"
#include "nsCRT.h"
@@ -646,25 +646,25 @@ static PRBool
SetupTextRunFromGlyphs(gfxTextRun *aRun, WCHAR *aGlyphs, HDC aDC,
gfxWindowsFont *aFont)
{
PRUint32 length = aRun->GetLength();
if (IsAnyGlyphMissing(aGlyphs, length))
return PR_FALSE;
SIZE size;
- nsAutoBuffer<int,500> partialWidthArray;
- if (!partialWidthArray.EnsureElemCapacity(length))
+ nsAutoTArray<int,500> 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;
aRun->AddGlyphRun(aFont, 0);
gfxTextRun::CompressedGlyph g;
PRUint32 i;
@@ -696,48 +696,48 @@ SetupTextRunFromGlyphs(gfxTextRun *aRun,
void
gfxWindowsFontGroup::InitTextRunGDI(gfxContext *aContext, gfxTextRun *aRun,
const char *aString, PRUint32 aLength)
{
nsRefPtr<gfxWindowsFont> font = GetFontAt(0);
DCFromContext dc(aContext);
if (SetupDCFont(dc, font)) {
- nsAutoBuffer<WCHAR,500> glyphArray;
- if (!glyphArray.EnsureElemCapacity(aLength))
+ nsAutoTArray<WCHAR,500> 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;
}
nsDependentCSubstring cString(aString, aString + aLength);
nsAutoString utf16;
AppendASCIItoUTF16(cString, utf16);
InitTextRunUniscribe(aContext, aRun, utf16.get(), aLength);
}
void
gfxWindowsFontGroup::InitTextRunGDI(gfxContext *aContext, gfxTextRun *aRun,
const PRUnichar *aString, PRUint32 aLength)
{
nsRefPtr<gfxWindowsFont> font = GetFontAt(0);
DCFromContext dc(aContext);
if (SetupDCFont(dc, font)) {
- nsAutoBuffer<WCHAR,500> glyphArray;
- if (!glyphArray.EnsureElemCapacity(aLength))
+ nsAutoTArray<WCHAR,500> 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;
}
InitTextRunUniscribe(aContext, aRun, aString, aLength);
}
/*******************
* Uniscribe
@@ -881,19 +881,19 @@ public:
gfxWindowsFontGroup *aGroup) :
mContext(aContext), mDC(aDC), mRangeString(nsnull), mRangeLength(0),
mItemString(aString), mItemLength(aLength),
mAlternativeString(nsnull), mScriptItem(aItem),
mScript(aItem->a.eScript), mGroup(aGroup),
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() {
free(mAlternativeString);
}
/* possible return values:
* S_OK - things succeeded
@@ -921,22 +921,22 @@ public:
if (mRangeString + mRangeLength < mItemString + mItemLength)
sa.fLinkAfter = PR_FALSE;
while (PR_TRUE) {
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;
}
if (rv == E_PENDING) {
if (shapeDC == mDC) {
// we already tried this once, something failed, give up
return GDI_ERROR;
@@ -944,17 +944,17 @@ public:
SelectFont();
shapeDC = mDC;
continue;
}
#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");
}
else if (FAILED(rv))
printf("%d\n", rv);
#endif
return rv;
@@ -984,26 +984,26 @@ public:
if (mGlyphs[aGlyphIndex] == aSFP->wgDefault)
return PR_TRUE;
return PR_FALSE;
}
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();
placeDC = mDC;
continue;
}
break;
@@ -1452,22 +1452,22 @@ private:
const PRUint32 mItemLength;
PRUnichar *mAlternativeString;
gfxWindowsFontGroup *mGroup;
#define AVERAGE_ITEM_LENGTH 40
- nsAutoBuffer<WORD, PRUint32(1.5 * AVERAGE_ITEM_LENGTH) + 16> mGlyphs;
- nsAutoBuffer<WORD, AVERAGE_ITEM_LENGTH + 1> mClusters;
- nsAutoBuffer<SCRIPT_VISATTR, PRUint32(1.5 * AVERAGE_ITEM_LENGTH) + 16> mAttr;
+ nsAutoTArray<WORD, PRUint32(1.5 * AVERAGE_ITEM_LENGTH) + 16> mGlyphs;
+ nsAutoTArray<WORD, AVERAGE_ITEM_LENGTH + 1> mClusters;
+ nsAutoTArray<SCRIPT_VISATTR, PRUint32(1.5 * AVERAGE_ITEM_LENGTH) + 16> mAttr;
- nsAutoBuffer<GOFFSET, 2 * AVERAGE_ITEM_LENGTH> mOffsets;
- nsAutoBuffer<int, 2 * AVERAGE_ITEM_LENGTH> mAdvances;
+ nsAutoTArray<GOFFSET, 2 * AVERAGE_ITEM_LENGTH> mOffsets;
+ nsAutoTArray<int, 2 * AVERAGE_ITEM_LENGTH> mAdvances;
#undef AVERAGE_ITEM_LENGTH
int mMaxGlyphs;
int mNumGlyphs;
nsRefPtr<gfxWindowsFont> mCurrentFont;
--- a/intl/locale/src/nsLocaleService.cpp
+++ b/intl/locale/src/nsLocaleService.cpp
@@ -39,17 +39,17 @@
#include "nsILocale.h"
#include "nsILocaleService.h"
#include "nsLocale.h"
#include "nsLocaleCID.h"
#include "nsServiceManagerUtils.h"
#include "nsReadableUtils.h"
#include "nsCRT.h"
#include "prprf.h"
-#include "nsAutoBuffer.h"
+#include "nsTArray.h"
#include <ctype.h>
#if defined(XP_WIN)
# include "nsIWin32Locale.h"
#elif defined(XP_OS2)
# include "unidef.h"
# include "nsIOS2Locale.h"
@@ -260,26 +260,26 @@ nsLocaleService::nsLocaleService(void)
#endif // XP_OS2
#ifdef XP_MACOSX
// Get string representation of user's current locale
CFLocaleRef userLocaleRef = ::CFLocaleCopyCurrent();
CFStringRef userLocaleStr = ::CFLocaleGetIdentifier(userLocaleRef);
::CFRetain(userLocaleStr);
- nsAutoBuffer<UniChar, 32> buffer;
+ nsAutoTArray<UniChar, 32> 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));
if (NS_SUCCEEDED(rv)) {
mApplicationLocale = mSystemLocale;
}
}
--- a/modules/libpr0n/decoders/icon/mac/nsIconChannelCocoa.mm
+++ b/modules/libpr0n/decoders/icon/mac/nsIconChannelCocoa.mm
@@ -52,17 +52,17 @@
#include "nsIURL.h"
#include "nsNetUtil.h"
#include "nsIMIMEService.h"
#include "nsCExternalHandlerService.h"
#include "plstr.h"
#include "nsILocalFileMac.h"
#include "nsIFileURL.h"
#include "nsInt64.h"
-#include "nsAutoBuffer.h"
+#include "nsTArray.h"
#include <Cocoa/Cocoa.h>
// nsIconChannel methods
nsIconChannel::nsIconChannel()
{
}
@@ -308,21 +308,21 @@ nsresult nsIconChannel::MakeInputStream(
[bitmapRep hasAlpha] == YES,
NS_ERROR_UNEXPECTED);
// rgba, pre-multiplied data
PRUint8* bitmapRepData = (PRUint8*)[bitmapRep bitmapData];
// create our buffer
PRInt32 bufferCapacity = 2 + desiredImageSize * desiredImageSize * 4;
- nsAutoBuffer<PRUint8, 3 + 16 * 16 * 5> iconBuffer; // initial size is for 16x16
- if (!iconBuffer.EnsureElemCapacity(bufferCapacity))
+ nsAutoTArray<PRUint8, 3 + 16 * 16 * 5> 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;
*iconBufferPtr++ = desiredImageSize;
PRUint32 dataCount = (desiredImageSize * desiredImageSize) * 4;
PRUint32 index = 0;
while (index < dataCount) {
@@ -343,27 +343,27 @@ nsresult nsIconChannel::MakeInputStream(
#else
*iconBufferPtr++ = a;
*iconBufferPtr++ = r;
*iconBufferPtr++ = g;
*iconBufferPtr++ = b;
#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
nsCOMPtr<nsIInputStream> inStream;
nsCOMPtr<nsIOutputStream> outStream;
rv = NS_NewPipe(getter_AddRefs(inStream), getter_AddRefs(outStream), bufferCapacity, bufferCapacity, nonBlocking);
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);
}
// Drop notification callbacks to prevent cycles.
mCallbacks = nsnull;
return NS_OK;
--- a/uriloader/exthandler/mac/nsOSHelperAppService.cpp
+++ b/uriloader/exthandler/mac/nsOSHelperAppService.cpp
@@ -35,17 +35,17 @@
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsOSHelperAppService.h"
#include "nsISupports.h"
#include "nsString.h"
-#include "nsAutoBuffer.h"
+#include "nsTArray.h"
#include "nsXPIDLString.h"
#include "nsIURL.h"
#include "nsILocalFile.h"
#include "nsILocalFileMac.h"
#include "nsMimeTypes.h"
#include "nsIStringBundle.h"
#include "nsIPromptService.h"
#include "nsMemory.h"
@@ -120,22 +120,22 @@ NS_IMETHODIMP nsOSHelperAppService::GetA
if (err == noErr) {
CFBundleRef handlerBundle = ::CFBundleCreate(NULL, handlerBundleURL);
if (handlerBundle) {
// Get the human-readable name of the default handler bundle
CFStringRef bundleName =
(CFStringRef)::CFBundleGetValueForInfoDictionaryKey(handlerBundle,
kCFBundleNameKey);
if (bundleName) {
- nsAutoBuffer<UniChar, 255> buffer;
+ nsAutoTArray<UniChar, 255> 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;
}
::CFRelease(handlerBundle);
}
::CFRelease(handlerBundleURL);
}
--- a/widget/src/os2/nsOS2Uni.cpp
+++ b/widget/src/os2/nsOS2Uni.cpp
@@ -142,22 +142,22 @@ WideCharToMultiByte(int aCodePage, const
{
nsresult rv;
nsISupports* sup = OS2Uni::GetUconvObject(aCodePage, eConv_Encoder);
nsCOMPtr<nsIUnicodeEncoder> uco = do_QueryInterface(sup);
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;
}
/**********************************************************
MultiByteToWideChar
**********************************************************/
nsresult
MultiByteToWideChar(int aCodePage, const char* aSrc,
@@ -166,16 +166,16 @@ MultiByteToWideChar(int aCodePage, const
{
nsresult rv;
nsISupports* sup = OS2Uni::GetUconvObject(aCodePage, eConv_Decoder);
nsCOMPtr<nsIUnicodeDecoder> uco = do_QueryInterface(sup);
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;
}
--- a/widget/src/os2/nsOS2Uni.h
+++ b/widget/src/os2/nsOS2Uni.h
@@ -35,17 +35,17 @@
* ***** END LICENSE BLOCK ***** */
#ifndef _nsos2uni_h
#define _nsos2uni_h
#define INCL_WIN
#include <os2.h>
#include <uconv.h>
-#include "nsAutoBuffer.h"
+#include "nsTArray.h"
#include "nsICharsetConverterManager.h"
#include "gfxCore.h"
enum ConverterRequest {
eConv_Encoder,
eConv_Decoder
};
@@ -53,18 +53,18 @@ class OS2Uni {
public:
static nsISupports* GetUconvObject(int CodePage, ConverterRequest aReq);
static void FreeUconvObjects();
private:
static nsICharsetConverterManager* gCharsetManager;
};
#define CHAR_BUFFER_SIZE 1024
-typedef nsAutoBuffer<char, CHAR_BUFFER_SIZE> nsAutoCharBuffer;
-typedef nsAutoBuffer<PRUnichar, CHAR_BUFFER_SIZE> nsAutoChar16Buffer;
+typedef nsAutoTArray<char, CHAR_BUFFER_SIZE> nsAutoCharBuffer;
+typedef nsAutoTArray<PRUnichar, CHAR_BUFFER_SIZE> nsAutoChar16Buffer;
nsresult WideCharToMultiByte(int aCodePage, const PRUnichar* aSrc,
PRInt32 aSrcLength, nsAutoCharBuffer& aResult,
PRInt32& aResultLength);
nsresult MultiByteToWideChar(int aCodePage, const char* aSrc,
PRInt32 aSrcLength, nsAutoChar16Buffer& aResult,
PRInt32& aResultLength);
--- a/xpcom/ds/Makefile.in
+++ b/xpcom/ds/Makefile.in
@@ -102,17 +102,16 @@ EXPORTS = \
nsSupportsArray.h \
nsSupportsPrimitives.h \
nsTime.h \
nsUnitConversion.h \
nsVariant.h \
nsTextFormatter.h \
nsValueArray.h \
nsStringEnumerator.h \
- nsAutoBuffer.h \
nsHashPropertyBag.h \
nsWhitespaceTokenizer.h \
$(NULL)
XPIDLSRCS = \
nsIAtom.idl \
nsIAtomService.idl \
nsICollection.idl \
--- a/xpcom/glue/nsTArray.h
+++ b/xpcom/glue/nsTArray.h
@@ -175,17 +175,22 @@ class NS_COM_GLUE nsTArray_base {
// This class defines convenience functions for element specific operations.
// Specialize this template if necessary.
//
template<class E>
class nsTArrayElementTraits {
public:
// Invoke the default constructor in place.
static inline void Construct(E *e) {
- new (static_cast<void *>(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<void *>(e)) E;
}
// Invoke the copy-constructor in place.
template<class A>
static inline void Construct(E *e, const A &arg) {
new (static_cast<void *>(e)) E(arg);
}
// Invoke the destructor in place.
static inline void Destruct(E *e) {
--- a/xpcom/io/nsLocalFileOSX.cpp
+++ b/xpcom/io/nsLocalFileOSX.cpp
@@ -53,17 +53,17 @@
#include "plbase64.h"
#include "prmem.h"
#include "nsCRT.h"
#include "nsHashKeys.h"
#include "MoreFilesX.h"
#include "FSCopyObject.h"
-#include "nsAutoBuffer.h"
+#include "nsTArray.h"
#include "nsTraceRefcntImpl.h"
// Mac Includes
#include <Carbon/Carbon.h>
// Unix Includes
#include <unistd.h>
#include <sys/stat.h>
@@ -478,32 +478,32 @@ NS_IMETHODIMP nsLocalFile::Create(PRUint
// Check we are correctly initialized.
CHECK_mBaseRef();
nsStringArray nonExtantNodes;
CFURLRef pathURLRef = mBaseRef;
FSRef pathFSRef;
CFStringRef leafStrRef = nsnull;
- nsAutoBuffer<UniChar, FILENAME_BUFFER_SIZE> buffer;
+ nsAutoTArray<UniChar, FILENAME_BUFFER_SIZE> buffer;
Boolean success;
// Work backwards through the path to find the last node which
// exists. Place the nodes which don't exist in an array and we'll
// create those below.
while ((success = ::CFURLGetFSRef(pathURLRef, &pathFSRef)) == false) {
leafStrRef = ::CFURLCopyLastPathComponent(pathURLRef);
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;
// Get the parent of the leaf for the next go round
CFURLRef parent = ::CFURLCreateCopyDeletingLastPathComponent(NULL, pathURLRef);
if (!parent)
break;
if (pathURLRef != mBaseRef)
@@ -2494,18 +2494,18 @@ static void CopyUTF8toUTF16NFC(const nsA
sUnicodeNormalizer(inStr, kCFStringNormalizationFormC);
CFIndex length = CFStringGetLength(inStr);
const UniChar* chars = CFStringGetCharactersPtr(inStr);
if (chars)
aResult.Assign(chars, length);
else {
- nsAutoBuffer<UniChar, FILENAME_BUFFER_SIZE> buffer;
- if (!buffer.EnsureElemCapacity(length))
+ nsAutoTArray<UniChar, FILENAME_BUFFER_SIZE> 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);
}
--- a/xpcom/obsolete/nsFileSpecUnix.cpp
+++ b/xpcom/obsolete/nsFileSpecUnix.cpp
@@ -45,17 +45,17 @@
#include <errno.h>
#include <dirent.h>
#include <unistd.h>
#include <stdlib.h>
#include <limits.h>
#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 */
#endif
#ifdef HAVE_SYS_STATVFS_H
#include <sys/statvfs.h>
#endif
@@ -759,19 +759,19 @@ static void CopyUTF8toUTF16NFC(const nsA
sUnicodeNormalizer(inStr, kCFStringNormalizationFormC);
CFIndex length = CFStringGetLength(inStr);
const UniChar* chars = CFStringGetCharactersPtr(inStr);
if (chars)
aResult.Assign(chars, length);
else {
- nsAutoBuffer<UniChar, 512> buffer;
- if (buffer.EnsureElemCapacity(length)) {
- CFStringGetCharacters(inStr, CFRangeMake(0, length), buffer.get());
- aResult.Assign(buffer.get(), length);
+ nsAutoTArray<UniChar, 512> buffer;
+ if (buffer.SetLength(length)) {
+ CFStringGetCharacters(inStr, CFRangeMake(0, length), buffer.Elements());
+ aResult.Assign(buffer.Elements(), length);
}
else
CopyUTF8toUTF16(aSrc, aResult);
}
CFRelease(inStr);
}
#endif