void AppendUTF8toUTF16( const nsACString& aSource, nsAString& aDest ) { if (!AppendUTF8toUTF16(aSource, aDest, mozilla::fallible_t())) { NS_ABORT_OOM(aDest.Length() + aSource.Length()); } }
void nsTString_CharT::StripChars( const char* aSet ) { if (!EnsureMutable()) NS_ABORT_OOM(mLength); mLength = nsBufferRoutines<CharT>::strip_chars(mData, mLength, aSet); }
void* nsPresArena::Allocate(uint32_t aCode, size_t aSize) { NS_ABORT_IF_FALSE(aSize > 0, "PresArena cannot allocate zero bytes"); // We only hand out aligned sizes aSize = PL_ARENA_ALIGN(&mPool, aSize); // If there is no free-list entry for this type already, we have // to create one now, to record its size. FreeList* list = mFreeLists.PutEntry(aCode); nsTArray<void*>::index_type len = list->mEntries.Length(); if (list->mEntrySize == 0) { NS_ABORT_IF_FALSE(len == 0, "list with entries but no recorded size"); list->mEntrySize = aSize; } else { NS_ABORT_IF_FALSE(list->mEntrySize == aSize, "different sizes for same object type code"); } void* result; if (len > 0) { // LIFO behavior for best cache utilization result = list->mEntries.ElementAt(len - 1); list->mEntries.RemoveElementAt(len - 1); #if defined(DEBUG) { MOZ_MAKE_MEM_DEFINED(result, list->mEntrySize); char* p = reinterpret_cast<char*>(result); char* limit = p + list->mEntrySize; for (; p < limit; p += sizeof(uintptr_t)) { uintptr_t val = *reinterpret_cast<uintptr_t*>(p); NS_ABORT_IF_FALSE(val == mozPoisonValue(), nsPrintfCString("PresArena: poison overwritten; " "wanted %.16llx " "found %.16llx " "errors in bits %.16llx", uint64_t(mozPoisonValue()), uint64_t(val), uint64_t(mozPoisonValue() ^ val) ).get()); } } #endif MOZ_MAKE_MEM_UNDEFINED(result, list->mEntrySize); return result; } // Allocate a new chunk from the arena list->mEntriesEverAllocated++; PL_ARENA_ALLOCATE(result, &mPool, aSize); if (!result) { NS_ABORT_OOM(aSize); } return result; }
void nsTString_CharT::ReplaceChar( char_type aOldChar, char_type aNewChar ) { if (!EnsureMutable()) // XXX do this lazily? NS_ABORT_OOM(mLength); for (uint32_t i=0; i<mLength; ++i) { if (mData[i] == aOldChar) mData[i] = aNewChar; } }
bool nsTString_CharT::SetCharAt( char16_t aChar, uint32_t aIndex ) { if (aIndex >= mLength) return false; if (!EnsureMutable()) NS_ABORT_OOM(mLength); mData[aIndex] = CharT(aChar); return true; }
bool ReportException(JNIEnv* aEnv, jthrowable aExc, jstring aStack) { bool result = true; #ifdef MOZ_CRASHREPORTER result &= NS_SUCCEEDED(CrashReporter::AnnotateCrashReport( NS_LITERAL_CSTRING("JavaStackTrace"), String::Ref::From(aStack)->ToCString())); #endif // MOZ_CRASHREPORTER if (sOOMErrorClass && aEnv->IsInstanceOf(aExc, sOOMErrorClass)) { NS_ABORT_OOM(0); // Unknown OOM size } return result; }
void nsString::ReplaceChar( const char16_t* aSet, char16_t aNewChar ) { if (!EnsureMutable()) // XXX do this lazily? NS_ABORT_OOM(mLength); char16_t* data = mData; uint32_t lenRemaining = mLength; while (lenRemaining) { int32_t i = ::FindCharInSet(data, lenRemaining, aSet); if (i == kNotFound) break; data[i++] = aNewChar; data += i; lenRemaining -= i; } }