本文整理汇总了C++中mozilla::fallible_t方法的典型用法代码示例。如果您正苦于以下问题:C++ mozilla::fallible_t方法的具体用法?C++ mozilla::fallible_t怎么用?C++ mozilla::fallible_t使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mozilla
的用法示例。
在下文中一共展示了mozilla::fallible_t方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetData
NS_IMETHODIMP nsSupportsStringImpl::SetData(const nsAString& aData)
{
bool ok = mData.Assign(aData, fallible_t());
if (!ok)
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
示例2:
NS_IMETHODIMP
nsUnicharStreamLoader::Init(nsIUnicharStreamLoaderObserver *aObserver)
{
NS_ENSURE_ARG_POINTER(aObserver);
mObserver = aObserver;
if (!mRawData.SetCapacity(SNIFFING_BUFFER_SIZE, fallible_t()))
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
示例3: while
NS_METHOD
nsUnicharStreamLoader::WriteSegmentFun(nsIInputStream *,
void *aClosure,
const char *aSegment,
PRUint32,
PRUint32 aCount,
PRUint32 *aWriteCount)
{
nsUnicharStreamLoader* self = static_cast<nsUnicharStreamLoader*>(aClosure);
PRUint32 haveRead = self->mBuffer.Length();
PRUint32 consumed = 0;
nsresult rv;
do {
PRInt32 srcLen = aCount - consumed;
PRInt32 dstLen;
self->mDecoder->GetMaxLength(aSegment + consumed, srcLen, &dstLen);
PRUint32 capacity = haveRead + dstLen;
if (!self->mBuffer.SetCapacity(capacity, fallible_t())) {
return NS_ERROR_OUT_OF_MEMORY;
}
rv = self->mDecoder->Convert(aSegment + consumed,
&srcLen,
self->mBuffer.BeginWriting() + haveRead,
&dstLen);
haveRead += dstLen;
// XXX if srcLen is negative, we want to drop the _first_ byte in
// the erroneous byte sequence and try again. This is not quite
// possible right now -- see bug 160784
consumed += srcLen;
if (NS_FAILED(rv)) {
NS_ASSERTION(0 < capacity - haveRead,
"Decoder returned an error but filled the output buffer! "
"Should not happen.");
self->mBuffer.BeginWriting()[haveRead++] = 0xFFFD;
++consumed;
// XXX this is needed to make sure we don't underrun our buffer;
// bug 160784 again
consumed = NS_MAX<PRUint32>(consumed, 0);
self->mDecoder->Reset();
}
} while (consumed < aCount);
self->mBuffer.SetLength(haveRead);
*aWriteCount = aCount;
return NS_OK;
}