mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1004098 - Make nsTArray use size_t in its interface (32bitness is fine as an internal detail) - r=froydnj, sr=bsmedberg
This commit is contained in:
parent
202dd3b43b
commit
2e1ef0025a
@ -79,7 +79,7 @@ nsXMLNameSpaceMap::AddPrefix(nsIAtom *aPrefix, nsString &aURI)
|
||||
int32_t
|
||||
nsXMLNameSpaceMap::FindNameSpaceID(nsIAtom *aPrefix) const
|
||||
{
|
||||
uint32_t index = mNameSpaces.IndexOf(aPrefix);
|
||||
size_t index = mNameSpaces.IndexOf(aPrefix);
|
||||
if (index != mNameSpaces.NoIndex) {
|
||||
return mNameSpaces[index].nameSpaceID;
|
||||
}
|
||||
@ -93,7 +93,7 @@ nsXMLNameSpaceMap::FindNameSpaceID(nsIAtom *aPrefix) const
|
||||
nsIAtom*
|
||||
nsXMLNameSpaceMap::FindPrefix(int32_t aNameSpaceID) const
|
||||
{
|
||||
uint32_t index = mNameSpaces.IndexOf(aNameSpaceID);
|
||||
size_t index = mNameSpaces.IndexOf(aNameSpaceID);
|
||||
if (index != mNameSpaces.NoIndex) {
|
||||
return mNameSpaces[index].prefix;
|
||||
}
|
||||
|
@ -1252,7 +1252,7 @@ HTMLFormElement::RemoveElement(nsGenericHTMLFormElement* aChild,
|
||||
|
||||
// Find the index of the child. This will be used later if necessary
|
||||
// to find the default submit.
|
||||
uint32_t index = controls.IndexOf(aChild);
|
||||
size_t index = controls.IndexOf(aChild);
|
||||
NS_ENSURE_STATE(index != controls.NoIndex);
|
||||
|
||||
controls.RemoveElementAt(index);
|
||||
@ -2339,7 +2339,7 @@ HTMLFormElement::AddImageElementToTable(HTMLImageElement* aChild,
|
||||
nsresult
|
||||
HTMLFormElement::RemoveImageElement(HTMLImageElement* aChild)
|
||||
{
|
||||
uint32_t index = mImageElements.IndexOf(aChild);
|
||||
size_t index = mImageElements.IndexOf(aChild);
|
||||
NS_ENSURE_STATE(index != mImageElements.NoIndex);
|
||||
|
||||
mImageElements.RemoveElementAt(index);
|
||||
|
@ -2518,7 +2518,7 @@ HTMLInputElement::GetDisplayFileName(nsAString& aValue) const
|
||||
}
|
||||
} else {
|
||||
nsString count;
|
||||
count.AppendInt(mFiles.Length());
|
||||
count.AppendInt(int(mFiles.Length()));
|
||||
|
||||
const char16_t* params[] = { count.get() };
|
||||
nsContentUtils::FormatLocalizedString(nsContentUtils::eFORMS_PROPERTIES,
|
||||
|
@ -31,14 +31,14 @@ AudioNodeExternalInputStream::TrackMapEntry::~TrackMapEntry()
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t
|
||||
size_t
|
||||
AudioNodeExternalInputStream::GetTrackMapEntry(const StreamBuffer::Track& aTrack,
|
||||
GraphTime aFrom)
|
||||
{
|
||||
AudioSegment* segment = aTrack.Get<AudioSegment>();
|
||||
|
||||
// Check the map for an existing entry corresponding to the input track.
|
||||
for (uint32_t i = 0; i < mTrackMap.Length(); ++i) {
|
||||
for (size_t i = 0; i < mTrackMap.Length(); ++i) {
|
||||
TrackMapEntry* map = &mTrackMap[i];
|
||||
if (map->mTrackID == aTrack.GetID()) {
|
||||
return i;
|
||||
@ -58,7 +58,7 @@ AudioNodeExternalInputStream::GetTrackMapEntry(const StreamBuffer::Track& aTrack
|
||||
// Create a speex resampler with the same sample rate and number of channels
|
||||
// as the track.
|
||||
SpeexResamplerState* resampler = nullptr;
|
||||
uint32_t channelCount = std::min((*ci).mChannelData.Length(),
|
||||
size_t channelCount = std::min((*ci).mChannelData.Length(),
|
||||
WebAudioUtils::MaxChannelCount);
|
||||
if (aTrack.GetRate() != mSampleRate) {
|
||||
resampler = speex_resampler_init(channelCount,
|
||||
@ -340,7 +340,7 @@ AudioNodeExternalInputStream::ProcessInput(GraphTime aFrom, GraphTime aTo,
|
||||
!tracks.IsEnded(); tracks.Next()) {
|
||||
const StreamBuffer::Track& inputTrack = *tracks;
|
||||
// Create a TrackMapEntry if necessary.
|
||||
uint32_t trackMapIndex = GetTrackMapEntry(inputTrack, aFrom);
|
||||
size_t trackMapIndex = GetTrackMapEntry(inputTrack, aFrom);
|
||||
// Maybe there's nothing in this track yet. If so, ignore it. (While the
|
||||
// track is only playing silence, we may not be able to determine the
|
||||
// correct number of channels to start resampling.)
|
||||
|
@ -92,8 +92,8 @@ private:
|
||||
* Creates a TrackMapEntry for the track, if needed. Returns the index
|
||||
* of the TrackMapEntry or NoIndex if no entry is needed yet.
|
||||
*/
|
||||
uint32_t GetTrackMapEntry(const StreamBuffer::Track& aTrack,
|
||||
GraphTime aFrom);
|
||||
size_t GetTrackMapEntry(const StreamBuffer::Track& aTrack,
|
||||
GraphTime aFrom);
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -29,8 +29,8 @@ EncodedBufferCache::AppendBuffer(nsTArray<uint8_t> & aBuf)
|
||||
if (mTempFileEnabled) {
|
||||
// has created temporary file, write buffer in it
|
||||
for (uint32_t i = 0; i < mEncodedBuffers.Length(); i++) {
|
||||
int64_t amount = PR_Write(mFD, mEncodedBuffers.ElementAt(i).Elements(), mEncodedBuffers.ElementAt(i).Length());
|
||||
if (amount < mEncodedBuffers.ElementAt(i).Length()) {
|
||||
int32_t amount = PR_Write(mFD, mEncodedBuffers.ElementAt(i).Elements(), mEncodedBuffers.ElementAt(i).Length());
|
||||
if (amount < 0 || size_t(amount) < mEncodedBuffers.ElementAt(i).Length()) {
|
||||
NS_WARNING("Failed to write media cache block!");
|
||||
}
|
||||
}
|
||||
|
@ -779,7 +779,7 @@ MediaCache::FindReusableBlock(TimeStamp aNow,
|
||||
{
|
||||
mReentrantMonitor.AssertCurrentThreadIn();
|
||||
|
||||
uint32_t length = std::min(uint32_t(aMaxSearchBlockIndex), mIndex.Length());
|
||||
uint32_t length = std::min(uint32_t(aMaxSearchBlockIndex), uint32_t(mIndex.Length()));
|
||||
|
||||
if (aForStream && aForStreamBlock > 0 &&
|
||||
uint32_t(aForStreamBlock) <= aForStream->mBlocks.Length()) {
|
||||
|
@ -144,7 +144,7 @@ private:
|
||||
uint32_t end = std::min(GetAtOffset(aOffset + aCount, nullptr) + 1, GetSize());
|
||||
for (uint32_t i = start; i < end; ++i) {
|
||||
ResourceItem* item = ResourceAt(i);
|
||||
uint32_t bytes = std::min(aCount, item->mData.Length() - offset);
|
||||
uint32_t bytes = std::min(aCount, uint32_t(item->mData.Length() - offset));
|
||||
if (bytes != 0) {
|
||||
memcpy(aDest, &item->mData[offset], bytes);
|
||||
offset = 0;
|
||||
|
@ -172,9 +172,9 @@ AnalyserNode::GetFloatFrequencyData(const Float32Array& aArray)
|
||||
}
|
||||
|
||||
float* buffer = aArray.Data();
|
||||
uint32_t length = std::min(aArray.Length(), mOutputBuffer.Length());
|
||||
size_t length = std::min(size_t(aArray.Length()), mOutputBuffer.Length());
|
||||
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
for (size_t i = 0; i < length; ++i) {
|
||||
buffer[i] = WebAudioUtils::ConvertLinearToDecibels(mOutputBuffer[i], mMinDecibels);
|
||||
}
|
||||
}
|
||||
@ -190,9 +190,9 @@ AnalyserNode::GetByteFrequencyData(const Uint8Array& aArray)
|
||||
const double rangeScaleFactor = 1.0 / (mMaxDecibels - mMinDecibels);
|
||||
|
||||
unsigned char* buffer = aArray.Data();
|
||||
uint32_t length = std::min(aArray.Length(), mOutputBuffer.Length());
|
||||
size_t length = std::min(size_t(aArray.Length()), mOutputBuffer.Length());
|
||||
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
for (size_t i = 0; i < length; ++i) {
|
||||
const double decibels = WebAudioUtils::ConvertLinearToDecibels(mOutputBuffer[i], mMinDecibels);
|
||||
// scale down the value to the range of [0, UCHAR_MAX]
|
||||
const double scaled = std::max(0.0, std::min(double(UCHAR_MAX),
|
||||
@ -205,9 +205,9 @@ void
|
||||
AnalyserNode::GetFloatTimeDomainData(const Float32Array& aArray)
|
||||
{
|
||||
float* buffer = aArray.Data();
|
||||
uint32_t length = std::min(aArray.Length(), mBuffer.Length());
|
||||
size_t length = std::min(size_t(aArray.Length()), mBuffer.Length());
|
||||
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
for (size_t i = 0; i < length; ++i) {
|
||||
buffer[i] = mBuffer[(i + mWriteIndex) % mBuffer.Length()];;
|
||||
}
|
||||
}
|
||||
@ -216,9 +216,9 @@ void
|
||||
AnalyserNode::GetByteTimeDomainData(const Uint8Array& aArray)
|
||||
{
|
||||
unsigned char* buffer = aArray.Data();
|
||||
uint32_t length = std::min(aArray.Length(), mBuffer.Length());
|
||||
size_t length = std::min(size_t(aArray.Length()), mBuffer.Length());
|
||||
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
for (size_t i = 0; i < length; ++i) {
|
||||
const float value = mBuffer[(i + mWriteIndex) % mBuffer.Length()];
|
||||
// scale the value to the range of [0, UCHAR_MAX]
|
||||
const float scaled = std::max(0.0f, std::min(float(UCHAR_MAX),
|
||||
|
@ -109,10 +109,10 @@ AudioNode::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
|
||||
}
|
||||
|
||||
template <class InputNode>
|
||||
static uint32_t
|
||||
static size_t
|
||||
FindIndexOfNode(const nsTArray<InputNode>& aInputNodes, const AudioNode* aNode)
|
||||
{
|
||||
for (uint32_t i = 0; i < aInputNodes.Length(); ++i) {
|
||||
for (size_t i = 0; i < aInputNodes.Length(); ++i) {
|
||||
if (aInputNodes[i].mInputNode == aNode) {
|
||||
return i;
|
||||
}
|
||||
@ -121,11 +121,11 @@ FindIndexOfNode(const nsTArray<InputNode>& aInputNodes, const AudioNode* aNode)
|
||||
}
|
||||
|
||||
template <class InputNode>
|
||||
static uint32_t
|
||||
static size_t
|
||||
FindIndexOfNodeWithPorts(const nsTArray<InputNode>& aInputNodes, const AudioNode* aNode,
|
||||
uint32_t aInputPort, uint32_t aOutputPort)
|
||||
{
|
||||
for (uint32_t i = 0; i < aInputNodes.Length(); ++i) {
|
||||
for (size_t i = 0; i < aInputNodes.Length(); ++i) {
|
||||
if (aInputNodes[i].mInputNode == aNode &&
|
||||
aInputNodes[i].mInputPort == aInputPort &&
|
||||
aInputNodes[i].mOutputPort == aOutputPort) {
|
||||
@ -147,27 +147,27 @@ AudioNode::DisconnectFromGraph()
|
||||
|
||||
// Disconnect inputs. We don't need them anymore.
|
||||
while (!mInputNodes.IsEmpty()) {
|
||||
uint32_t i = mInputNodes.Length() - 1;
|
||||
size_t i = mInputNodes.Length() - 1;
|
||||
nsRefPtr<AudioNode> input = mInputNodes[i].mInputNode;
|
||||
mInputNodes.RemoveElementAt(i);
|
||||
input->mOutputNodes.RemoveElement(this);
|
||||
}
|
||||
|
||||
while (!mOutputNodes.IsEmpty()) {
|
||||
uint32_t i = mOutputNodes.Length() - 1;
|
||||
size_t i = mOutputNodes.Length() - 1;
|
||||
nsRefPtr<AudioNode> output = mOutputNodes[i].forget();
|
||||
mOutputNodes.RemoveElementAt(i);
|
||||
uint32_t inputIndex = FindIndexOfNode(output->mInputNodes, this);
|
||||
size_t inputIndex = FindIndexOfNode(output->mInputNodes, this);
|
||||
// It doesn't matter which one we remove, since we're going to remove all
|
||||
// entries for this node anyway.
|
||||
output->mInputNodes.RemoveElementAt(inputIndex);
|
||||
}
|
||||
|
||||
while (!mOutputParams.IsEmpty()) {
|
||||
uint32_t i = mOutputParams.Length() - 1;
|
||||
size_t i = mOutputParams.Length() - 1;
|
||||
nsRefPtr<AudioParam> output = mOutputParams[i].forget();
|
||||
mOutputParams.RemoveElementAt(i);
|
||||
uint32_t inputIndex = FindIndexOfNode(output->InputNodes(), this);
|
||||
size_t inputIndex = FindIndexOfNode(output->InputNodes(), this);
|
||||
// It doesn't matter which one we remove, since we're going to remove all
|
||||
// entries for this node anyway.
|
||||
output->RemoveInputNode(inputIndex);
|
||||
|
@ -16,7 +16,7 @@ namespace dom {
|
||||
|
||||
// 32 is the minimum required by the spec and matches what is used by blink.
|
||||
// The limit protects against large memory allocations.
|
||||
const uint32_t WebAudioUtils::MaxChannelCount = 32;
|
||||
const size_t WebAudioUtils::MaxChannelCount = 32;
|
||||
|
||||
struct ConvertTimeToTickHelper
|
||||
{
|
||||
|
@ -25,7 +25,7 @@ namespace dom {
|
||||
class AudioParamTimeline;
|
||||
|
||||
struct WebAudioUtils {
|
||||
static const uint32_t MaxChannelCount;
|
||||
static const size_t MaxChannelCount;
|
||||
|
||||
static bool FuzzyEqual(float v1, float v2)
|
||||
{
|
||||
|
@ -1033,7 +1033,7 @@ XULDocument::AttributeChanged(nsIDocument* aDocument,
|
||||
attrSet,
|
||||
needsAttrChange);
|
||||
|
||||
uint32_t index =
|
||||
size_t index =
|
||||
mDelayedAttrChangeBroadcasts.IndexOf(delayedUpdate,
|
||||
0, nsDelayedBroadcastUpdate::Comparator());
|
||||
if (index != mDelayedAttrChangeBroadcasts.NoIndex) {
|
||||
|
@ -258,7 +258,7 @@ TransactionThreadPool::FinishTransaction(IDBTransaction* aTransaction)
|
||||
NS_ASSERTION(info, "We've never heard of this transaction?!?");
|
||||
|
||||
const nsTArray<nsString>& objectStoreNames = aTransaction->mObjectStoreNames;
|
||||
for (uint32_t index = 0, count = objectStoreNames.Length(); index < count;
|
||||
for (size_t index = 0, count = objectStoreNames.Length(); index < count;
|
||||
index++) {
|
||||
TransactionInfoPair* blockInfo =
|
||||
dbTransactionInfo->blockingTransactions.Get(objectStoreNames[index]);
|
||||
@ -269,7 +269,7 @@ TransactionThreadPool::FinishTransaction(IDBTransaction* aTransaction)
|
||||
blockInfo->lastBlockingReads = nullptr;
|
||||
}
|
||||
|
||||
uint32_t i = blockInfo->lastBlockingWrites.IndexOf(info);
|
||||
size_t i = blockInfo->lastBlockingWrites.IndexOf(info);
|
||||
if (i != blockInfo->lastBlockingWrites.NoIndex) {
|
||||
blockInfo->lastBlockingWrites.RemoveElementAt(i);
|
||||
}
|
||||
|
@ -1455,7 +1455,7 @@ TabChild::RecvCacheFileDescriptor(const nsString& aPath,
|
||||
|
||||
// First see if we already have a request for this path.
|
||||
const CachedFileDescriptorInfo search(aPath);
|
||||
uint32_t index =
|
||||
size_t index =
|
||||
mCachedFileDescriptorInfos.IndexOf(search, 0,
|
||||
search.PathOnlyComparator());
|
||||
if (index == mCachedFileDescriptorInfos.NoIndex) {
|
||||
@ -1507,7 +1507,7 @@ TabChild::GetCachedFileDescriptor(const nsAString& aPath,
|
||||
// First see if we've already received a cached file descriptor for this
|
||||
// path.
|
||||
const CachedFileDescriptorInfo search(aPath);
|
||||
uint32_t index =
|
||||
size_t index =
|
||||
mCachedFileDescriptorInfos.IndexOf(search, 0,
|
||||
search.PathOnlyComparator());
|
||||
if (index == mCachedFileDescriptorInfos.NoIndex) {
|
||||
@ -1563,7 +1563,7 @@ TabChild::CancelCachedFileDescriptorCallback(
|
||||
}
|
||||
|
||||
const CachedFileDescriptorInfo search(aPath, aCallback);
|
||||
uint32_t index =
|
||||
size_t index =
|
||||
mCachedFileDescriptorInfos.IndexOf(search, 0,
|
||||
search.PathAndCallbackComparator());
|
||||
if (index == mCachedFileDescriptorInfos.NoIndex) {
|
||||
|
@ -3113,13 +3113,13 @@ WorkerPrivateParent<Derived>::BroadcastErrorToSharedWorkers(
|
||||
// First fire the error event at all SharedWorker objects. This may include
|
||||
// multiple objects in a single window as well as objects in different
|
||||
// windows.
|
||||
for (uint32_t index = 0; index < sharedWorkers.Length(); index++) {
|
||||
for (size_t index = 0; index < sharedWorkers.Length(); index++) {
|
||||
nsRefPtr<SharedWorker>& sharedWorker = sharedWorkers[index];
|
||||
|
||||
// May be null.
|
||||
nsPIDOMWindow* window = sharedWorker->GetOwner();
|
||||
|
||||
uint32_t actionsIndex = windowActions.LastIndexOf(WindowAction(window));
|
||||
size_t actionsIndex = windowActions.LastIndexOf(WindowAction(window));
|
||||
|
||||
// Get the context for this window so that we can report errors correctly.
|
||||
JSContext* cx;
|
||||
|
@ -179,14 +179,14 @@ nsAnonymousContentList::IndexOf(nsIContent* aContent)
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint32_t index = 0;
|
||||
size_t index = 0;
|
||||
for (nsIContent* child = mParent->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
if (child->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL)) {
|
||||
XBLChildrenElement* point = static_cast<XBLChildrenElement*>(child);
|
||||
if (!point->mInsertedChildren.IsEmpty()) {
|
||||
uint32_t insIndex = point->mInsertedChildren.IndexOf(aContent);
|
||||
size_t insIndex = point->mInsertedChildren.IndexOf(aContent);
|
||||
if (insIndex != point->mInsertedChildren.NoIndex) {
|
||||
return index + insIndex;
|
||||
}
|
||||
@ -195,7 +195,7 @@ nsAnonymousContentList::IndexOf(nsIContent* aContent)
|
||||
else {
|
||||
int32_t insIndex = point->IndexOf(aContent);
|
||||
if (insIndex != -1) {
|
||||
return index + (uint32_t)insIndex;
|
||||
return index + (size_t)insIndex;
|
||||
}
|
||||
index += point->GetChildCount();
|
||||
}
|
||||
|
@ -334,7 +334,7 @@ nsBindingManager::RemoveFromAttachedQueue(nsXBLBinding* aBinding)
|
||||
{
|
||||
// Don't remove items here as that could mess up an executing
|
||||
// ProcessAttachedQueue. Instead, null the entry in the queue.
|
||||
uint32_t index = mAttachedStack.IndexOf(aBinding);
|
||||
size_t index = mAttachedStack.IndexOf(aBinding);
|
||||
if (index != mAttachedStack.NoIndex) {
|
||||
mAttachedStack[index] = nullptr;
|
||||
}
|
||||
@ -840,7 +840,7 @@ static void
|
||||
InsertAppendedContent(XBLChildrenElement* aPoint,
|
||||
nsIContent* aFirstNewContent)
|
||||
{
|
||||
uint32_t insertionIndex;
|
||||
size_t insertionIndex;
|
||||
if (nsIContent* prevSibling = aFirstNewContent->GetPreviousSibling()) {
|
||||
// If we have a previous sibling, then it must already be in aPoint. Find
|
||||
// it and insert after it.
|
||||
@ -1083,14 +1083,14 @@ nsBindingManager::HandleChildInsertion(nsIContent* aContainer,
|
||||
// TODO If there were multiple insertion points, this approximation can be
|
||||
// wrong. We need to re-run the distribution algorithm. In the meantime,
|
||||
// this should work well enough.
|
||||
uint32_t index = aAppend ? point->mInsertedChildren.Length() : 0;
|
||||
size_t index = aAppend ? point->mInsertedChildren.Length() : 0;
|
||||
for (nsIContent* currentSibling = aChild->GetPreviousSibling();
|
||||
currentSibling;
|
||||
currentSibling = currentSibling->GetPreviousSibling()) {
|
||||
// If we find one of our previous siblings in the insertion point, the
|
||||
// index following it is the correct insertion point. Otherwise, we guess
|
||||
// based on whether we're appending or inserting.
|
||||
uint32_t pointIndex = point->IndexOfInsertedChild(currentSibling);
|
||||
size_t pointIndex = point->IndexOfInsertedChild(currentSibling);
|
||||
if (pointIndex != point->NoIndex) {
|
||||
index = pointIndex + 1;
|
||||
break;
|
||||
|
@ -26,7 +26,7 @@ class txMapItemComparator
|
||||
nsresult txExpandedNameMap_base::addItem(const txExpandedName& aKey,
|
||||
void* aValue)
|
||||
{
|
||||
uint32_t pos = mItems.IndexOf(aKey, 0, txMapItemComparator());
|
||||
size_t pos = mItems.IndexOf(aKey, 0, txMapItemComparator());
|
||||
if (pos != mItems.NoIndex) {
|
||||
return NS_ERROR_XSLT_ALREADY_SET;
|
||||
}
|
||||
@ -53,11 +53,10 @@ nsresult txExpandedNameMap_base::setItem(const txExpandedName& aKey,
|
||||
void** aOldValue)
|
||||
{
|
||||
*aOldValue = nullptr;
|
||||
uint32_t pos = mItems.IndexOf(aKey, 0, txMapItemComparator());
|
||||
size_t pos = mItems.IndexOf(aKey, 0, txMapItemComparator());
|
||||
if (pos != mItems.NoIndex) {
|
||||
*aOldValue = mItems[pos].mValue;
|
||||
mItems[pos].mValue = aValue;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -78,7 +77,7 @@ nsresult txExpandedNameMap_base::setItem(const txExpandedName& aKey,
|
||||
*/
|
||||
void* txExpandedNameMap_base::getItem(const txExpandedName& aKey) const
|
||||
{
|
||||
uint32_t pos = mItems.IndexOf(aKey, 0, txMapItemComparator());
|
||||
size_t pos = mItems.IndexOf(aKey, 0, txMapItemComparator());
|
||||
if (pos != mItems.NoIndex) {
|
||||
return mItems[pos].mValue;
|
||||
}
|
||||
@ -95,7 +94,7 @@ void* txExpandedNameMap_base::getItem(const txExpandedName& aKey) const
|
||||
void* txExpandedNameMap_base::removeItem(const txExpandedName& aKey)
|
||||
{
|
||||
void* value = nullptr;
|
||||
uint32_t pos = mItems.IndexOf(aKey, 0, txMapItemComparator());
|
||||
size_t pos = mItems.IndexOf(aKey, 0, txMapItemComparator());
|
||||
if (pos != mItems.NoIndex) {
|
||||
value = mItems[pos].mValue;
|
||||
mItems.RemoveElementAt(pos);
|
||||
|
@ -8145,8 +8145,8 @@ nsHTMLEditRules::RemoveEmptyNodes()
|
||||
NS_ENSURE_TRUE(node, NS_ERROR_FAILURE);
|
||||
|
||||
nsINode* parent = node->GetParentNode();
|
||||
|
||||
uint32_t idx = skipList.IndexOf(node);
|
||||
|
||||
size_t idx = skipList.IndexOf(node);
|
||||
if (idx != skipList.NoIndex) {
|
||||
// this node is on our skip list. Skip processing for this node,
|
||||
// and replace its value in the skip list with the value of its parent
|
||||
|
@ -3012,7 +3012,7 @@ nsresult
|
||||
nsHTMLEditor::RemoveStyleSheetFromList(const nsAString &aURL)
|
||||
{
|
||||
// is it already in the list?
|
||||
uint32_t foundIndex;
|
||||
size_t foundIndex;
|
||||
foundIndex = mStyleSheetURLs.IndexOf(aURL);
|
||||
if (foundIndex == mStyleSheetURLs.NoIndex)
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -3032,7 +3032,7 @@ nsHTMLEditor::GetStyleSheetForURL(const nsAString &aURL,
|
||||
*aStyleSheet = 0;
|
||||
|
||||
// is it already in the list?
|
||||
uint32_t foundIndex;
|
||||
size_t foundIndex;
|
||||
foundIndex = mStyleSheetURLs.IndexOf(aURL);
|
||||
if (foundIndex == mStyleSheetURLs.NoIndex)
|
||||
return NS_OK; //No sheet -- don't fail!
|
||||
|
@ -404,7 +404,7 @@ DisplayTable::GetColormapAndVisual(Screen* aScreen, XRenderPictFormat* aFormat,
|
||||
}
|
||||
|
||||
nsTArray<DisplayInfo>* displays = &sDisplayTable->mDisplays;
|
||||
uint32_t d = displays->IndexOf(display, 0, FindDisplay());
|
||||
size_t d = displays->IndexOf(display, 0, FindDisplay());
|
||||
|
||||
if (d == displays->NoIndex) {
|
||||
d = displays->Length();
|
||||
|
@ -2861,7 +2861,7 @@ RasterImage::RequestDiscard()
|
||||
|
||||
// Flushes up to aMaxBytes to the decoder.
|
||||
nsresult
|
||||
RasterImage::DecodeSomeData(uint32_t aMaxBytes, DecodeStrategy aStrategy)
|
||||
RasterImage::DecodeSomeData(size_t aMaxBytes, DecodeStrategy aStrategy)
|
||||
{
|
||||
// We should have a decoder if we get here
|
||||
NS_ABORT_IF_FALSE(mDecoder, "trying to decode without decoder!");
|
||||
@ -2886,8 +2886,8 @@ RasterImage::DecodeSomeData(uint32_t aMaxBytes, DecodeStrategy aStrategy)
|
||||
MOZ_ASSERT(mBytesDecoded < mSourceData.Length());
|
||||
|
||||
// write the proper amount of data
|
||||
uint32_t bytesToDecode = std::min(aMaxBytes,
|
||||
mSourceData.Length() - mBytesDecoded);
|
||||
size_t bytesToDecode = std::min(aMaxBytes,
|
||||
mSourceData.Length() - mBytesDecoded);
|
||||
nsresult rv = WriteToDecoder(mSourceData.Elements() + mBytesDecoded,
|
||||
bytesToDecode,
|
||||
aStrategy);
|
||||
@ -3384,7 +3384,7 @@ RasterImage::DecodePool::DecodeJob::Run()
|
||||
|
||||
mRequest->mRequestStatus = DecodeRequest::REQUEST_ACTIVE;
|
||||
|
||||
uint32_t oldByteCount = mImage->mBytesDecoded;
|
||||
size_t oldByteCount = mImage->mBytesDecoded;
|
||||
|
||||
DecodeType type = DECODE_TYPE_UNTIL_DONE_BYTES;
|
||||
|
||||
@ -3396,7 +3396,7 @@ RasterImage::DecodePool::DecodeJob::Run()
|
||||
|
||||
DecodePool::Singleton()->DecodeSomeOfImage(mImage, DECODE_ASYNC, type, mRequest->mBytesToDecode);
|
||||
|
||||
uint32_t bytesDecoded = mImage->mBytesDecoded - oldByteCount;
|
||||
size_t bytesDecoded = mImage->mBytesDecoded - oldByteCount;
|
||||
|
||||
mRequest->mRequestStatus = DecodeRequest::REQUEST_WORK_DONE;
|
||||
|
||||
|
@ -369,7 +369,7 @@ private:
|
||||
|
||||
RasterImage* mImage;
|
||||
|
||||
uint32_t mBytesToDecode;
|
||||
size_t mBytesToDecode;
|
||||
|
||||
enum DecodeRequestStatus
|
||||
{
|
||||
@ -681,7 +681,7 @@ private: // data
|
||||
// Decoder and friends
|
||||
nsRefPtr<Decoder> mDecoder;
|
||||
nsRefPtr<DecodeRequest> mDecodeRequest;
|
||||
uint32_t mBytesDecoded;
|
||||
size_t mBytesDecoded;
|
||||
|
||||
bool mInDecoder;
|
||||
// END LOCKED MEMBER VARIABLES
|
||||
@ -729,7 +729,7 @@ private: // data
|
||||
nsresult SyncDecode();
|
||||
nsresult InitDecoder(bool aDoSizeDecode);
|
||||
nsresult WriteToDecoder(const char *aBuffer, uint32_t aCount, DecodeStrategy aStrategy);
|
||||
nsresult DecodeSomeData(uint32_t aMaxBytes, DecodeStrategy aStrategy);
|
||||
nsresult DecodeSomeData(size_t aMaxBytes, DecodeStrategy aStrategy);
|
||||
bool IsDecodeFinished();
|
||||
TimeStamp mDrawStartTime;
|
||||
|
||||
|
@ -316,7 +316,7 @@ uint32_t
|
||||
DisplayItemClip::GetCommonRoundedRectCount(const DisplayItemClip& aOther,
|
||||
uint32_t aMax) const
|
||||
{
|
||||
uint32_t end = std::min(std::min(mRoundedClipRects.Length(), aMax),
|
||||
uint32_t end = std::min(std::min(mRoundedClipRects.Length(), size_t(aMax)),
|
||||
aOther.mRoundedClipRects.Length());
|
||||
uint32_t clipCount = 0;
|
||||
for (; clipCount < end; ++clipCount) {
|
||||
@ -331,7 +331,7 @@ DisplayItemClip::GetCommonRoundedRectCount(const DisplayItemClip& aOther,
|
||||
void
|
||||
DisplayItemClip::AppendRoundedRects(nsTArray<RoundedRect>* aArray, uint32_t aCount) const
|
||||
{
|
||||
uint32_t count = std::min(mRoundedClipRects.Length(), aCount);
|
||||
uint32_t count = std::min(mRoundedClipRects.Length(), size_t(aCount));
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
*aArray->AppendElement() = mRoundedClipRects[i];
|
||||
}
|
||||
|
@ -2117,7 +2117,7 @@ BuildTextRunsScanner::BuildTextRunForFrames(void* aTextBuffer)
|
||||
gfxTextRunFactory::Parameters params =
|
||||
{ mContext, finalUserData, &skipChars,
|
||||
textBreakPointsAfterTransform.Elements(),
|
||||
textBreakPointsAfterTransform.Length(),
|
||||
uint32_t(textBreakPointsAfterTransform.Length()),
|
||||
int32_t(firstFrame->PresContext()->AppUnitsPerDevPixel())};
|
||||
|
||||
if (mDoubleByteText) {
|
||||
|
@ -574,12 +574,12 @@ nsTransitionManager::ConsiderStartingTransition(nsCSSProperty aProperty,
|
||||
0.5, dummyValue);
|
||||
|
||||
bool haveCurrentTransition = false;
|
||||
uint32_t currentIndex = nsTArray<ElementPropertyTransition>::NoIndex;
|
||||
size_t currentIndex = nsTArray<ElementPropertyTransition>::NoIndex;
|
||||
const ElementPropertyTransition *oldPT = nullptr;
|
||||
if (aElementTransitions) {
|
||||
nsTArray<ElementPropertyTransition> &pts =
|
||||
aElementTransitions->mPropertyTransitions;
|
||||
for (uint32_t i = 0, i_end = pts.Length(); i < i_end; ++i) {
|
||||
for (size_t i = 0, i_end = pts.Length(); i < i_end; ++i) {
|
||||
MOZ_ASSERT(pts[i].mProperties.Length() == 1,
|
||||
"Should have one animation property for a transition");
|
||||
if (pts[i].mProperties[0].mProperty == aProperty) {
|
||||
|
@ -718,7 +718,7 @@ nsTableCellMap::Dump(char* aString) const
|
||||
const nsColInfo& colInfo = mCols.ElementAt(colX);
|
||||
printf ("%d=%d/%d ", colX, colInfo.mNumCellsOrig, colInfo.mNumCellsSpan);
|
||||
}
|
||||
printf(" cols in cache %d\n", mTableFrame.GetColCache().Length());
|
||||
printf(" cols in cache %d\n", int(mTableFrame.GetColCache().Length()));
|
||||
nsCellMap* cellMap = mFirstMap;
|
||||
while (cellMap) {
|
||||
cellMap->Dump(nullptr != mBCInfo);
|
||||
@ -2183,7 +2183,7 @@ void nsCellMap::ShrinkWithoutCell(nsTableCellMap& aMap,
|
||||
// endIndexForRow points at the first slot we don't want to clean up. This
|
||||
// makes the aColIndex == 0 case work right with our unsigned int colX.
|
||||
NS_ASSERTION(endColIndex + 1 <= row.Length(), "span beyond the row size!");
|
||||
uint32_t endIndexForRow = std::min(endColIndex + 1, row.Length());
|
||||
uint32_t endIndexForRow = std::min(endColIndex + 1, uint32_t(row.Length()));
|
||||
|
||||
// Since endIndexForRow <= row.Length(), enough to compare aColIndex to it.
|
||||
if (uint32_t(aColIndex) < endIndexForRow) {
|
||||
|
@ -2929,7 +2929,7 @@ nsTableFrame::ReflowChildren(nsTableReflowState& aReflowState,
|
||||
}
|
||||
// if the child is a tbody in paginated mode reduce the height by a repeated footer
|
||||
bool allowRepeatedFooter = false;
|
||||
for (uint32_t childX = 0; childX < rowGroups.Length(); childX++) {
|
||||
for (size_t childX = 0; childX < rowGroups.Length(); childX++) {
|
||||
nsIFrame* kidFrame = rowGroups[childX];
|
||||
// Get the frame state bits
|
||||
// See if we should only reflow the dirty child frames
|
||||
|
@ -195,7 +195,7 @@ nsMenuBarFrame::FindMenuWithShortcut(nsIDOMKeyEvent* aKeyEvent)
|
||||
|
||||
// Find a most preferred accesskey which should be returned.
|
||||
nsIFrame* foundMenu = nullptr;
|
||||
uint32_t foundIndex = accessKeys.NoIndex;
|
||||
size_t foundIndex = accessKeys.NoIndex;
|
||||
nsIFrame* currFrame = immediateParent->GetFirstPrincipalChild();
|
||||
|
||||
while (currFrame) {
|
||||
@ -211,7 +211,7 @@ nsMenuBarFrame::FindMenuWithShortcut(nsIDOMKeyEvent* aKeyEvent)
|
||||
const char16_t* start = shortcutKey.BeginReading();
|
||||
const char16_t* end = shortcutKey.EndReading();
|
||||
uint32_t ch = UTF16CharEnumerator::NextChar(&start, end);
|
||||
uint32_t index = accessKeys.IndexOf(ch);
|
||||
size_t index = accessKeys.IndexOf(ch);
|
||||
if (index != accessKeys.NoIndex &&
|
||||
(foundIndex == accessKeys.NoIndex || index < foundIndex)) {
|
||||
foundMenu = currFrame;
|
||||
|
@ -15,10 +15,10 @@
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsClassHashtable.h"
|
||||
#include "nsHashKeys.h"
|
||||
#include "nsTArrayForwardDeclare.h"
|
||||
|
||||
class nsIHashable;
|
||||
class nsIRemoteOpenFileListener;
|
||||
template<class E, uint32_t N> class nsAutoTArray;
|
||||
|
||||
class nsJARProtocolHandler : public nsIJARProtocolHandler
|
||||
, public nsSupportsWeakReference
|
||||
|
@ -55,7 +55,7 @@ nsresult
|
||||
NS_RemoveWeakElementBase(isupports_array_type *aArray,
|
||||
nsISupports *aElement)
|
||||
{
|
||||
uint32_t index = aArray->IndexOf(aElement);
|
||||
size_t index = aArray->IndexOf(aElement);
|
||||
if (index != aArray->NoIndex) {
|
||||
aArray->RemoveElementAt(index);
|
||||
return NS_OK;
|
||||
|
@ -39,7 +39,7 @@ ChunkSet::Serialize(nsACString& aChunkStr)
|
||||
nsresult
|
||||
ChunkSet::Set(uint32_t aChunk)
|
||||
{
|
||||
uint32_t idx = mChunks.BinaryIndexOf(aChunk);
|
||||
size_t idx = mChunks.BinaryIndexOf(aChunk);
|
||||
if (idx == nsTArray<uint32_t>::NoIndex) {
|
||||
mChunks.InsertElementSorted(aChunk);
|
||||
}
|
||||
|
@ -737,7 +737,7 @@ Classifier::ReadNoiseEntries(const Prefix& aPrefix,
|
||||
nsresult rv = cache->GetPrefixes(&prefixes);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
uint32_t idx = prefixes.BinaryIndexOf(aPrefix.ToUint32());
|
||||
size_t idx = prefixes.BinaryIndexOf(aPrefix.ToUint32());
|
||||
|
||||
if (idx == nsTArray<uint32_t>::NoIndex) {
|
||||
NS_WARNING("Could not find prefix in PrefixSet during noise lookup");
|
||||
@ -746,7 +746,7 @@ Classifier::ReadNoiseEntries(const Prefix& aPrefix,
|
||||
|
||||
idx -= idx % aCount;
|
||||
|
||||
for (uint32_t i = 0; (i < aCount) && ((idx+i) < prefixes.Length()); i++) {
|
||||
for (size_t i = 0; (i < aCount) && ((idx+i) < prefixes.Length()); i++) {
|
||||
Prefix newPref;
|
||||
newPref.FromUint32(prefixes[idx+i]);
|
||||
if (newPref != aPrefix) {
|
||||
|
@ -37,10 +37,10 @@ Notes to self:
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsTransferable, nsITransferable)
|
||||
|
||||
uint32_t GetDataForFlavor (const nsTArray<DataStruct>& aArray,
|
||||
size_t GetDataForFlavor (const nsTArray<DataStruct>& aArray,
|
||||
const char* aDataFlavor)
|
||||
{
|
||||
for (uint32_t i = 0 ; i < aArray.Length () ; ++i) {
|
||||
for (size_t i = 0 ; i < aArray.Length () ; ++i) {
|
||||
if (aArray[i].GetFlavor().Equals (aDataFlavor))
|
||||
return i;
|
||||
}
|
||||
@ -542,7 +542,7 @@ nsTransferable::FlavorsTransferableCanImport(nsISupportsArray **_retval)
|
||||
uint32_t importListLen;
|
||||
convertedList->Count(&importListLen);
|
||||
|
||||
for ( uint32_t i=0; i < importListLen; ++i ) {
|
||||
for (uint32_t i = 0; i < importListLen; ++i ) {
|
||||
nsCOMPtr<nsISupports> genericFlavor;
|
||||
convertedList->GetElementAt ( i, getter_AddRefs(genericFlavor) );
|
||||
|
||||
|
@ -177,7 +177,7 @@ template <class T, uint32_t K> class nsExpirationTracker {
|
||||
// the indexes of objects in this generation to *decrease*, not increase.
|
||||
// So if we start from the end and work our way backwards we are guaranteed
|
||||
// to see each object at least once.
|
||||
uint32_t index = generation.Length();
|
||||
size_t index = generation.Length();
|
||||
for (;;) {
|
||||
// Objects could have been removed so index could be outside
|
||||
// the array
|
||||
|
@ -181,9 +181,7 @@ private:
|
||||
typedef nsTArray<PLHashEntry*> HashEntryArray;
|
||||
typedef typename HashEntryArray::index_type index_type;
|
||||
typedef typename HashEntryArray::size_type size_type;
|
||||
enum {
|
||||
NoIndex = HashEntryArray::NoIndex
|
||||
};
|
||||
static const HashEntryArray::index_type NoIndex = HashEntryArray::NoIndex;
|
||||
|
||||
/**
|
||||
* Value type for the ordering table. Contains the other
|
||||
|
@ -95,6 +95,9 @@ bool nsTArray_base<Alloc, Copy>::UsesAutoArrayBuffer() const {
|
||||
return mHdr == GetAutoArrayBuffer(4) || mHdr == GetAutoArrayBuffer(8);
|
||||
}
|
||||
|
||||
// defined in nsTArray.cpp
|
||||
bool
|
||||
IsTwiceTheRequiredBytesRepresentableAsUint32(size_t capacity, size_t elemSize);
|
||||
|
||||
template<class Alloc, class Copy>
|
||||
typename Alloc::ResultTypeProxy
|
||||
@ -105,10 +108,10 @@ nsTArray_base<Alloc, Copy>::EnsureCapacity(size_type capacity, size_type elemSiz
|
||||
|
||||
// If the requested memory allocation exceeds size_type(-1)/2, then
|
||||
// our doubling algorithm may not be able to allocate it.
|
||||
// Additionally we couldn't fit in the Header::mCapacity
|
||||
// member. Just bail out in cases like that. We don't want to be
|
||||
// allocating 2 GB+ arrays anyway.
|
||||
if ((uint64_t)capacity * elemSize > size_type(-1)/2) {
|
||||
// Additionally, if it exceeds uint32_t(-1) then we couldn't fit in the
|
||||
// Header::mCapacity member. Just bail out in cases like that. We don't want
|
||||
// to be allocating 2 GB+ arrays anyway.
|
||||
if (!IsTwiceTheRequiredBytesRepresentableAsUint32(capacity, elemSize)) {
|
||||
Alloc::SizeTooBig((size_t)capacity * elemSize);
|
||||
return Alloc::FailureResult();
|
||||
}
|
||||
@ -130,11 +133,11 @@ nsTArray_base<Alloc, Copy>::EnsureCapacity(size_type capacity, size_type elemSiz
|
||||
// We increase our capacity so |capacity * elemSize + sizeof(Header)| is the
|
||||
// next power of two, if this value is less than pageSize bytes, or otherwise
|
||||
// so it's the next multiple of pageSize.
|
||||
const uint32_t pageSizeBytes = 12;
|
||||
const uint32_t pageSize = 1 << pageSizeBytes;
|
||||
const size_t pageSizeBytes = 12;
|
||||
const size_t pageSize = 1 << pageSizeBytes;
|
||||
|
||||
uint32_t minBytes = capacity * elemSize + sizeof(Header);
|
||||
uint32_t bytesToAlloc;
|
||||
size_t minBytes = capacity * elemSize + sizeof(Header);
|
||||
size_t bytesToAlloc;
|
||||
if (minBytes >= pageSize) {
|
||||
// Round up to the next multiple of pageSize.
|
||||
bytesToAlloc = pageSize * ((minBytes + pageSize - 1) / pageSize);
|
||||
@ -173,7 +176,7 @@ nsTArray_base<Alloc, Copy>::EnsureCapacity(size_type capacity, size_type elemSiz
|
||||
}
|
||||
|
||||
// How many elements can we fit in bytesToAlloc?
|
||||
uint32_t newCapacity = (bytesToAlloc - sizeof(Header)) / elemSize;
|
||||
size_t newCapacity = (bytesToAlloc - sizeof(Header)) / elemSize;
|
||||
MOZ_ASSERT(newCapacity >= capacity, "Didn't enlarge the array enough!");
|
||||
header->mCapacity = newCapacity;
|
||||
|
||||
|
@ -8,5 +8,12 @@
|
||||
#include "nsTArray.h"
|
||||
#include "nsXPCOM.h"
|
||||
#include "nsDebug.h"
|
||||
#include "mozilla/CheckedInt.h"
|
||||
|
||||
nsTArrayHeader nsTArrayHeader::sEmptyHdr = { 0, 0, 0 };
|
||||
|
||||
bool
|
||||
IsTwiceTheRequiredBytesRepresentableAsUint32(size_t capacity, size_t elemSize) {
|
||||
using mozilla::CheckedUint32;
|
||||
return ((CheckedUint32(capacity) * elemSize) * 2).isValid();
|
||||
}
|
||||
|
@ -285,7 +285,7 @@ template <class E, class Derived>
|
||||
struct nsTArray_SafeElementAtHelper
|
||||
{
|
||||
typedef E* elem_type;
|
||||
typedef uint32_t index_type;
|
||||
typedef size_t index_type;
|
||||
|
||||
// No implementation is provided for these two methods, and that is on
|
||||
// purpose, since we don't support these functions on non-pointer type
|
||||
@ -298,7 +298,7 @@ template <class E, class Derived>
|
||||
struct nsTArray_SafeElementAtHelper<E*, Derived>
|
||||
{
|
||||
typedef E* elem_type;
|
||||
typedef uint32_t index_type;
|
||||
typedef size_t index_type;
|
||||
|
||||
elem_type SafeElementAt(index_type i) {
|
||||
return static_cast<Derived*> (this)->SafeElementAt(i, nullptr);
|
||||
@ -315,7 +315,7 @@ template <class E, class Derived>
|
||||
struct nsTArray_SafeElementAtSmartPtrHelper
|
||||
{
|
||||
typedef E* elem_type;
|
||||
typedef uint32_t index_type;
|
||||
typedef size_t index_type;
|
||||
|
||||
elem_type SafeElementAt(index_type i) {
|
||||
return static_cast<Derived*> (this)->SafeElementAt(i, nullptr);
|
||||
@ -360,8 +360,8 @@ protected:
|
||||
typedef nsTArrayHeader Header;
|
||||
|
||||
public:
|
||||
typedef uint32_t size_type;
|
||||
typedef uint32_t index_type;
|
||||
typedef size_t size_type;
|
||||
typedef size_t index_type;
|
||||
|
||||
// @return The number of elements in the array.
|
||||
size_type Length() const {
|
||||
@ -417,7 +417,7 @@ protected:
|
||||
// Note that mHdr may actually be sEmptyHdr in the case where a
|
||||
// zero-length array is inserted into our array. But then n should
|
||||
// always be 0.
|
||||
void IncrementLength(uint32_t n) {
|
||||
void IncrementLength(size_t n) {
|
||||
if (mHdr == EmptyHdr()) {
|
||||
if (MOZ_UNLIKELY(n != 0)) {
|
||||
// Writing a non-zero length to the empty header would be extremely bad.
|
||||
@ -1644,8 +1644,8 @@ ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
|
||||
uint32_t aFlags = 0)
|
||||
{
|
||||
aFlags |= CycleCollectionEdgeNameArrayFlag;
|
||||
uint32_t length = aField.Length();
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
size_t length = aField.Length();
|
||||
for (size_t i = 0; i < length; ++i) {
|
||||
ImplCycleCollectionTraverse(aCallback, aField[i], aName, aFlags);
|
||||
}
|
||||
}
|
||||
@ -1693,7 +1693,7 @@ public:
|
||||
// nsAutoArrayBase is a base class for AutoFallibleTArray and nsAutoTArray.
|
||||
// You shouldn't use this class directly.
|
||||
//
|
||||
template <class TArrayBase, uint32_t N>
|
||||
template <class TArrayBase, size_t N>
|
||||
class nsAutoArrayBase : public TArrayBase
|
||||
{
|
||||
public:
|
||||
@ -1764,7 +1764,7 @@ private:
|
||||
// Note that you can cast an nsAutoTArray<E, N> to
|
||||
// |const AutoFallibleTArray<E, N>&|.
|
||||
//
|
||||
template<class E, uint32_t N>
|
||||
template<class E, size_t N>
|
||||
class nsAutoTArray : public nsAutoArrayBase<nsTArray<E>, N>
|
||||
{
|
||||
typedef nsAutoTArray<E, N> self_type;
|
||||
@ -1787,7 +1787,7 @@ public:
|
||||
// AutoFallibleTArray<E, N> is a fallible vector class with N elements of
|
||||
// inline storage.
|
||||
//
|
||||
template<class E, uint32_t N>
|
||||
template<class E, size_t N>
|
||||
class AutoFallibleTArray : public nsAutoArrayBase<FallibleTArray<E>, N>
|
||||
{
|
||||
typedef AutoFallibleTArray<E, N> self_type;
|
||||
|
@ -19,7 +19,7 @@
|
||||
// template parameters.
|
||||
//
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
template<class E>
|
||||
class nsTArray;
|
||||
@ -27,10 +27,10 @@ class nsTArray;
|
||||
template<class E>
|
||||
class FallibleTArray;
|
||||
|
||||
template<class E, uint32_t N>
|
||||
template<class E, size_t N>
|
||||
class nsAutoTArray;
|
||||
|
||||
template<class E, uint32_t N>
|
||||
template<class E, size_t N>
|
||||
class AutoFallibleTArray;
|
||||
|
||||
#define InfallibleTArray nsTArray
|
||||
|
@ -22,9 +22,9 @@
|
||||
|
||||
class NS_COM_GLUE nsTObserverArray_base {
|
||||
public:
|
||||
typedef uint32_t index_type;
|
||||
typedef uint32_t size_type;
|
||||
typedef int32_t diff_type;
|
||||
typedef size_t index_type;
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t diff_type;
|
||||
|
||||
protected:
|
||||
class Iterator_base {
|
||||
@ -69,7 +69,7 @@ class NS_COM_GLUE nsTObserverArray_base {
|
||||
mutable Iterator_base* mIterators;
|
||||
};
|
||||
|
||||
template<class T, uint32_t N>
|
||||
template<class T, size_t N>
|
||||
class nsAutoTObserverArray : protected nsTObserverArray_base {
|
||||
public:
|
||||
typedef T elem_type;
|
||||
@ -415,14 +415,14 @@ class nsTObserverArray : public nsAutoTObserverArray<T, 0> {
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, uint32_t N>
|
||||
template <typename T, size_t N>
|
||||
inline void
|
||||
ImplCycleCollectionUnlink(nsAutoTObserverArray<T, N>& aField)
|
||||
{
|
||||
aField.Clear();
|
||||
}
|
||||
|
||||
template <typename T, uint32_t N>
|
||||
template <typename T, size_t N>
|
||||
inline void
|
||||
ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
|
||||
nsAutoTObserverArray<T, N>& aField,
|
||||
@ -430,8 +430,8 @@ ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
|
||||
uint32_t aFlags = 0)
|
||||
{
|
||||
aFlags |= CycleCollectionEdgeNameArrayFlag;
|
||||
uint32_t length = aField.Length();
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
size_t length = aField.Length();
|
||||
for (size_t i = 0; i < length; ++i) {
|
||||
ImplCycleCollectionTraverse(aCallback, aField.ElementAt(i), aName, aFlags);
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
#include "nsTArray.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsStringAPI.h"
|
||||
@ -31,8 +32,8 @@ inline bool operator<(const nsCOMPtr<T>& lhs, const nsCOMPtr<T>& rhs) {
|
||||
|
||||
template <class ElementType>
|
||||
static bool test_basic_array(ElementType *data,
|
||||
uint32_t dataLen,
|
||||
const ElementType& extra) {
|
||||
size_t dataLen,
|
||||
const ElementType& extra) {
|
||||
nsTArray<ElementType> ary;
|
||||
ary.AppendElements(data, dataLen);
|
||||
if (ary.Length() != dataLen) {
|
||||
@ -41,7 +42,7 @@ static bool test_basic_array(ElementType *data,
|
||||
if (!(ary == ary)) {
|
||||
return false;
|
||||
}
|
||||
uint32_t i;
|
||||
size_t i;
|
||||
for (i = 0; i < ary.Length(); ++i) {
|
||||
if (ary[i] != data[i])
|
||||
return false;
|
||||
@ -55,7 +56,7 @@ static bool test_basic_array(ElementType *data,
|
||||
return false;
|
||||
// ensure sort results in ascending order
|
||||
ary.Sort();
|
||||
uint32_t j = 0, k = ary.IndexOfFirstElementGt(extra);
|
||||
size_t j = 0, k = ary.IndexOfFirstElementGt(extra);
|
||||
if (k != 0 && ary[k-1] == extra)
|
||||
return false;
|
||||
for (i = 0; i < ary.Length(); ++i) {
|
||||
@ -81,23 +82,23 @@ static bool test_basic_array(ElementType *data,
|
||||
}
|
||||
if (ary.BinaryIndexOf(extra) != ary.NoIndex)
|
||||
return false;
|
||||
uint32_t oldLen = ary.Length();
|
||||
size_t oldLen = ary.Length();
|
||||
ary.RemoveElement(data[dataLen / 2]);
|
||||
if (ary.Length() != (oldLen - 1))
|
||||
return false;
|
||||
if (!(ary == ary))
|
||||
return false;
|
||||
|
||||
uint32_t index = ary.Length() / 2;
|
||||
size_t index = ary.Length() / 2;
|
||||
if (!ary.InsertElementAt(index, extra))
|
||||
return false;
|
||||
if (!(ary == ary))
|
||||
return false;
|
||||
if (ary[index] != extra)
|
||||
return false;
|
||||
if (ary.IndexOf(extra) == UINT32_MAX)
|
||||
if (ary.IndexOf(extra) == ary.NoIndex)
|
||||
return false;
|
||||
if (ary.LastIndexOf(extra) == UINT32_MAX)
|
||||
if (ary.LastIndexOf(extra) == ary.NoIndex)
|
||||
return false;
|
||||
// ensure proper searching
|
||||
if (ary.IndexOf(extra) > ary.LastIndexOf(extra))
|
||||
@ -114,16 +115,16 @@ static bool test_basic_array(ElementType *data,
|
||||
}
|
||||
if (!ary.AppendElements(copy))
|
||||
return false;
|
||||
uint32_t cap = ary.Capacity();
|
||||
size_t cap = ary.Capacity();
|
||||
ary.RemoveElementsAt(copy.Length(), copy.Length());
|
||||
ary.Compact();
|
||||
if (ary.Capacity() == cap)
|
||||
return false;
|
||||
|
||||
ary.Clear();
|
||||
if (ary.IndexOf(extra) != UINT32_MAX)
|
||||
if (ary.IndexOf(extra) != ary.NoIndex)
|
||||
return false;
|
||||
if (ary.LastIndexOf(extra) != UINT32_MAX)
|
||||
if (ary.LastIndexOf(extra) != ary.NoIndex)
|
||||
return false;
|
||||
|
||||
ary.Clear();
|
||||
@ -225,7 +226,7 @@ class Object {
|
||||
static bool test_object_array() {
|
||||
nsTArray<Object> objArray;
|
||||
const char kdata[] = "hello world";
|
||||
uint32_t i;
|
||||
size_t i;
|
||||
for (i = 0; i < ArrayLength(kdata); ++i) {
|
||||
char x[] = {kdata[i],'\0'};
|
||||
if (!objArray.AppendElement(Object(x, i)))
|
||||
@ -251,7 +252,7 @@ static bool test_object_array() {
|
||||
static bool test_autoptr_array() {
|
||||
nsTArray< nsAutoPtr<Object> > objArray;
|
||||
const char kdata[] = "hello world";
|
||||
for (uint32_t i = 0; i < ArrayLength(kdata); ++i) {
|
||||
for (size_t i = 0; i < ArrayLength(kdata); ++i) {
|
||||
char x[] = {kdata[i],'\0'};
|
||||
nsAutoPtr<Object> obj(new Object(x,i));
|
||||
if (!objArray.AppendElement(obj)) // XXX does not call copy-constructor for nsAutoPtr!!!
|
||||
@ -260,7 +261,7 @@ static bool test_autoptr_array() {
|
||||
return false;
|
||||
obj.forget(); // the array now owns the reference
|
||||
}
|
||||
for (uint32_t i = 0; i < ArrayLength(kdata); ++i) {
|
||||
for (size_t i = 0; i < ArrayLength(kdata); ++i) {
|
||||
if (objArray[i]->Str()[0] != kdata[i])
|
||||
return false;
|
||||
if (objArray[i]->Num() != i)
|
||||
@ -275,7 +276,7 @@ static bool test_autoptr_array() {
|
||||
static bool test_string_array() {
|
||||
nsTArray<nsCString> strArray;
|
||||
const char kdata[] = "hello world";
|
||||
uint32_t i;
|
||||
size_t i;
|
||||
for (i = 0; i < ArrayLength(kdata); ++i) {
|
||||
nsCString str;
|
||||
str.Assign(kdata[i]);
|
||||
@ -288,7 +289,7 @@ static bool test_string_array() {
|
||||
}
|
||||
|
||||
const char kextra[] = "foo bar";
|
||||
uint32_t oldLen = strArray.Length();
|
||||
size_t oldLen = strArray.Length();
|
||||
if (!strArray.AppendElement(kextra))
|
||||
return false;
|
||||
strArray.RemoveElement(kextra);
|
||||
@ -342,7 +343,7 @@ static bool test_comptr_array() {
|
||||
"foo.txt", "bar.html", "baz.gif"
|
||||
};
|
||||
nsTArray<FilePointer> fileArray;
|
||||
uint32_t i;
|
||||
size_t i;
|
||||
for (i = 0; i < ArrayLength(kNames); ++i) {
|
||||
FilePointer f;
|
||||
tmpDir->Clone(getter_AddRefs(f));
|
||||
@ -474,7 +475,7 @@ static bool test_autoarray() {
|
||||
return false;
|
||||
if (hdr == array2.DebugGetHeader())
|
||||
return false;
|
||||
uint32_t i;
|
||||
size_t i;
|
||||
for (i = 0; i < ArrayLength(data); ++i) {
|
||||
if (array2[i] != data[i])
|
||||
return false;
|
||||
@ -519,8 +520,8 @@ static bool test_indexof() {
|
||||
//----
|
||||
|
||||
template <class Array>
|
||||
static bool is_heap(const Array& ary, uint32_t len) {
|
||||
uint32_t index = 1;
|
||||
static bool is_heap(const Array& ary, size_t len) {
|
||||
size_t index = 1;
|
||||
while (index < len) {
|
||||
if (ary[index] > ary[(index - 1) >> 1])
|
||||
return false;
|
||||
@ -548,7 +549,7 @@ static bool test_heap() {
|
||||
return false;
|
||||
// make sure the heap looks like what we expect
|
||||
const int expected_data[] = {8,7,5,6,4,1,4,2,3};
|
||||
uint32_t index;
|
||||
size_t index;
|
||||
for (index = 0; index < ArrayLength(data); index++)
|
||||
if (ary[index] != expected_data[index])
|
||||
return false;
|
||||
@ -595,16 +596,18 @@ static bool test_heap() {
|
||||
#define CHECK_EQ_INT(actual, expected) \
|
||||
do { \
|
||||
if ((actual) != (expected)) { \
|
||||
printf("%s:%d CHECK_EQ_INT(%s=%u, %s=%u) failed.\n", \
|
||||
__FILE__, __LINE__, #actual, (actual), #expected, (expected)); \
|
||||
return false; \
|
||||
std::cout << __FILE__ << ":" << __LINE__ << " CHECK_EQ_INT(" \
|
||||
<< #actual << "=" << (actual) << ", " \
|
||||
<< #expected << "=" << (expected) << ") failed." \
|
||||
<< std::endl; \
|
||||
return false; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define CHECK_ARRAY(arr, data) \
|
||||
do { \
|
||||
CHECK_EQ_INT((arr).Length(), (uint32_t)ArrayLength(data)); \
|
||||
for (uint32_t _i = 0; _i < ArrayLength(data); _i++) { \
|
||||
CHECK_EQ_INT((arr).Length(), (size_t)ArrayLength(data)); \
|
||||
for (size_t _i = 0; _i < ArrayLength(data); _i++) { \
|
||||
CHECK_EQ_INT((arr)[_i], (data)[_i]); \
|
||||
} \
|
||||
} while(0)
|
||||
@ -755,7 +758,7 @@ static bool test_swap() {
|
||||
b.AppendElements(data2, ArrayLength(data2));
|
||||
|
||||
CHECK_EQ_INT(a.Capacity(), 0);
|
||||
uint32_t bCapacity = b.Capacity();
|
||||
size_t bCapacity = b.Capacity();
|
||||
|
||||
a.SwapElements(b);
|
||||
|
||||
@ -852,12 +855,12 @@ static bool test_fallible()
|
||||
// 36 * 128MB > 4GB, so we should definitely OOM by the 36th array.
|
||||
const unsigned numArrays = 36;
|
||||
FallibleTArray<char> arrays[numArrays];
|
||||
for (uint32_t i = 0; i < numArrays; i++) {
|
||||
for (size_t i = 0; i < numArrays; i++) {
|
||||
bool success = arrays[i].SetCapacity(128 * 1024 * 1024);
|
||||
if (!success) {
|
||||
// We got our OOM. Check that it didn't come too early.
|
||||
if (i < 8) {
|
||||
printf("test_fallible: Got OOM on iteration %d. Too early!\n", i);
|
||||
printf("test_fallible: Got OOM on iteration %d. Too early!\n", int(i));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user